After the action gives the error access_denied will work for me I can't go to the authorization page

After the action gives the error access_denied will work for me I can’t go to the authorization page. I can’t go to the authorization form.

Action: exports.onExecutePostLogin = async (event, api) => {
if (!event.user.email_verified) {
api.access.deny(‘Please verify your email before logging in!’);
}
};

If I try to go to the authorization page manually I get:

Hi there @mozgche6 welcome to the community!

You might want to look into using Redirect With Actions in order to redirect users to a specific url after being denied.

Hope this helps!

1 Like

Hi @tyf !

I changed the action to redirect, but it didn’t solve the problem (I still can’t go to the login form page):
exports.onExecutePostLogin = async (event, api) => {
if (!event.user.email_verified) {
api.redirect.sendUserTo(‘http://localhost:3000/error’, {
query: { message: ‘Please verify your email before logging in!’ }
});
}
};

I think that after an error, something is written to the cookie file, because if I delete it, I can go to the login/registration form. It also helps to call logout from useAuth0 to go to the login page (at the moment we have settled on this solution). Can you suggest something else?

Thanks for following up on this! I unfortunately do not have an alternate solution currently - I think calling logout instead may make the most sense here as this clears out the users session(s) entirely.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.