Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
identify(auth.profile, _.get(auth, 'user.roles'));
analyticsIdentitySet = true;
}
if (auth.tokenV3 !== (tctV3 || null)) {
const action = actions.auth.loadProfile(tctV3);
action.payload.then((profile) => {
if (!profile) return;
const user = decodeToken(tctV3);
const userId = profile && profile.userId;
const prevUserId = _.get(store.getState(), 'auth.profile.userId');
if (userId && userId !== prevUserId) {
identify(profile, _.get(auth, user.roles));
analyticsIdentitySet = true;
}
});
store.dispatch(actions.auth.setTcTokenV3(tctV3));
store.dispatch(action);
}
if (auth.tokenV2 !== (tctV2 || null)) {
store.dispatch(actions.auth.setTcTokenV2(tctV2));
}
const userV3 = tctV3 ? decodeToken(tctV3) : {};
const prevUserV3 = auth.tokenV3 ? decodeToken(auth.tokenV3) : {};
/* If we enter the following "if" block, it means that our visitor used
* to be authenticated before, but now he has lost his authentication;
* or he has authenticated as a different user. In both cases, we must drop
* from the state all sensitive data, accessible only to specific users. */
if (prevUserV3.handle && prevUserV3.handle !== userV3.handle) {
store.dispatch(actions.direct.dropAll());
store.dispatch(actions.groups.dropGroups());
const action = actions.auth.loadProfile(tctV3);
action.payload.then((profile) => {
if (!profile) return;
const user = decodeToken(tctV3);
const userId = profile && profile.userId;
const prevUserId = _.get(store.getState(), 'auth.profile.userId');
if (userId && userId !== prevUserId) {
identify(profile, _.get(auth, user.roles));
analyticsIdentitySet = true;
}
});
store.dispatch(actions.auth.setTcTokenV3(tctV3));
store.dispatch(action);
}
if (auth.tokenV2 !== (tctV2 || null)) {
store.dispatch(actions.auth.setTcTokenV2(tctV2));
}
const userV3 = tctV3 ? decodeToken(tctV3) : {};
const prevUserV3 = auth.tokenV3 ? decodeToken(auth.tokenV3) : {};
/* If we enter the following "if" block, it means that our visitor used
* to be authenticated before, but now he has lost his authentication;
* or he has authenticated as a different user. In both cases, we must drop
* from the state all sensitive data, accessible only to specific users. */
if (prevUserV3.handle && prevUserV3.handle !== userV3.handle) {
store.dispatch(actions.direct.dropAll());
store.dispatch(actions.groups.dropGroups());
}
/* Automatic refreshment of auth tokens. */
let time = Number.MAX_VALUE;