Auth0 Home Blog Docs

Redirect a user to url via Auth0 Rules

I am currently using multiple rules to evaluate different user stages. This is the first rule that gets executed. However the rule redirection to the custom URL is not working. Also new users are getting redirected to the application and not the custom URL. The URL was already added to the list of Allowed Callback URLs.

function (user, context, callback) {

  console.log('RULE: Running Set roles of new users');
  console.log('[before] user.app_metadata: ' + user.app_metadata);
  user.app_metadata = user.app_metadata || {};

  if (user.app_metadata.signedUp) {
    console.log('This is not the first sign in.');
    return callback(null, user, context);

    user.app_metadata.signedUp = true;
    user.app_metadata.roles = ["Not Approved user"];
    auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
      .then(function () {
        console.log('[after] user.app_metadata: ' + user.app_metadata);
        context.redirect = {          
          url: ""
      console.log('Redirect to custom success page');
      return callback(null, user, context);
      .catch(function (err) {

However this line gets fired and the output is visible in the console. console.log('Redirect to custom success page');

Why is the redirection not working?


Hey there!

Let me check it and get back to you with my thoughts!

So first things first:

Can you check whether the first bullet point is not a problem here? Thank you!

@konrad.sopala If the authentication is successful, the user gets redirected to the application.

If a user creates an account via Auth0 Lock they get automatically signed in. That’s their first sign in and and they should get redirected to a custom webpage on my server that says: “SignUp was successful”
I have a rules that takes care of this.

For more information please check the rules in my tenant because of the sensitivity of the data.

@konrad.sopala Any new ideas on this?