Returning unauthrized error in rule call back sends to unresolved url. cant continue

Hi,
we have the following rule - we would like to raise a flag and discontinue login based on a certain logic
how ever the callback is received with error and state, and nothing can be done.
we would like to show a certain error page or custom error page but it looks the app goes to a dead end trying to load that error url page over and over again.
we are using latest Angular as a frontend.
errored url:

http://localhost:4200/?error=unauthorized&error_description=some%20text&state=dzF1UXJIWmVLQm5sUGtRaUw4T3Z4bjh1cWlmfmxGc3NBd2oxSTJMdVpKRQ%3D%3D

rule:

function (user, context, callback) {
  user.app_metadata = user.app_metadata || {};
  if (user.app_metadata.some_boolean) {
    
    return callback(new UnauthorizedError('some text'), user, context);
    //return callback(null, user, context);
  } else {
    
    return callback(null, user, context);
  }
}
1 Like

Hey @cardauth

This is the method that Auth0 uses to send the authorization response back to the application.
Basically, your Angular frontend will have to look at the URL for the error and error_description parameters in the query string and, when found, use them to display an error page.

For example, in the Angular quickstart, you would handle that here: https://github.com/auth0-samples/auth0-angular-samples/blob/master/01-Login/src/app/auth/auth.service.ts#L88-L114

E.g.

  if (params.includes('error=')  {
    // show an error page

Hey nicolas_sabena.
thanks for the reply.
unfortunatly it doesnt work,
trying to redirect or any line of code in the scope keeps the page refreshed with the same error in the url
nothing happens…
im able to call the logout from that block, but i want to show an error page to the user.
still struggling.