Im looking to redirect the user to different pages depending on whether theyve signed in or signed up. api.redirect doesnt seem to be available on onExecutePostUserRegistration. How can i trigger a custom redirect?
Hi @bernardcooley,
Welcome to the Auth0 Community!
Unfortunately, the Post User Registration Action does not allow for a redirect as you discovered. The only way to use a redirect action is in a Post Login Action script.
One workaround I can offer is to use a Post Login Action to redirect your users based on their login count. Let me emphasize that whenever a sign-up is complete, it automatically logs the user in. Given that, we can redirect sign-up users by checking if their logins_count value equals 1.
For example:
exports.onExecutePostLogin = async (event, api) => {
if(event.stats.logins_count > 1){
//log in users
api.redirect.sendUserTo("FIRST_URL");
} else {
//sign up users
api.redirect.sendUserTo("SECOND_URL" };
};
exports.onContinuePostLogin = async (event, api) => {
}
Reference Materials:
Please let me know if you have any additional questions.
Thanks,
Rueben
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.