How to use the topcoder-react-lib.actions.auth function in topcoder-react-lib

To help you get started, we’ve selected a few topcoder-react-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github topcoder-platform / community-app / src / client / index.jsx View on Github external
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());
github topcoder-platform / community-app / src / client / index.jsx View on Github external
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;