Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
}
}
}
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 (
/>
<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'
),
}}
/>
</div></header></form>