How to use the strapi-helper-plugin.auth.getToken function in strapi-helper-plugin

To help you get started, we’ve selected a few strapi-helper-plugin 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 strapi / strapi / packages / strapi-plugin-users-permissions / admin / src / containers / AuthPage / index.js View on Github external
submitSuccess,
    } = this.props;

    if (authType !== prevProps.match.params.authType) {
      this.setForm();
      hideLoginErrorsInput(false);
    }

    if (submitSuccess) {
      switch (authType) {
        case 'login':
        case 'reset-password':
          // Check if we have token to handle redirection to login or admin.
          // Done to prevent redirection to admin after reset password if user should
          // not have access.
          auth.getToken()
            ? this.redirect('/')
            : this.redirect('/plugins/users-permissions/auth/login');
          break;
        case 'register':
          this.redirect('/');
          // NOTE: prepare for comfirm email;
          // this.redirect(`/plugins/users-permissions/auth/register-success/${this.props.modifiedData.email}`);
          break;
        default:
      }
    }
  }
github strapi / strapi / packages / strapi-admin / admin / src / containers / AuthPage / index.js View on Github external
formErrors = getYupInnerErrors(err);
    }

    dispatch({
      type: 'SET_ERRORS',
      formErrors,
    });
  };

  // Redirect the user to the login page if the endpoint does not exist
  if (!Object.keys(forms).includes(authType)) {
    return ;
  }

  // Redirect the user to the homepage if he is logged in
  if (auth.getToken()) {
    return ;
  }

  if (!hasAdminUser && authType !== 'register') {
    return ;
  }

  // Prevent the user from registering to the admin
  if (hasAdminUser && authType === 'register') {
    return ;
  }

  const globalError = get(errors, 'global.0.id', '');
  const shouldShowFormErrors = !isEmpty(globalError);

  return (
github strapi / strapi / packages / strapi-plugin-documentation / admin / src / containers / HomePage / index.js View on Github external
/>
        <form>
          <header title="{{">
          
            
              
                <div style="{{">
                  <input type="string" value="{auth.getToken()}" name="jwtToken" style="{{"> {}}
                    label={{ id: getTrad('containers.HomePage.form.jwtToken') }}
                    inputDescription={{
                      id: getTrad(
                        'containers.HomePage.form.jwtToken.description'
                      ),
                    }}
                  /&gt;
                </div></header></form>