Unauthorized Error Handling on SPA

I am checking user-approved status like this,

if (user.app_metadata && user.app_metadata.approved) {
    return callback(new UnauthorizedError('Your registration must be approved by an administrator.'));
  callback(null, user, context);

Issues 1: Upon login using Unapproved user credentials, I got an unauthorized error in the browser URL.

Issues 2: After this, error app reloads again and again and store cookies. After some attempts page, a blank page is shown and everything stop, not even loading app until i delete cookies.

I want to know
1: how to handle above thrown error on SPA
2: how to get rid of this reloading the app in the loop and deleting the cookies

Thanks Community.

Good morning,

As far as I know, we don’t have any plans to support catching error messages from the rules on the universal login page.

You could try redirecting users from within rules (https://auth0.com/docs/rules/guides/redirect). Also, I would recommend checking out this documentation: https://auth0.com/docs/universal-login/custom-error-pages



Good Morning,
Sure, I will try this.