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: "https://example.com"
};
console.log('Redirect to custom success page');
return callback(null, user, context);
})
.catch(function (err) {
callback(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?