I am in the midst of migrating my Rules to Post Login Actions, starting from the end of the Rules flow as the migration documents suggest. Everything has worked fine until I got to a rule that requires a redirect if we detect that a user attempting to login with a social provider is already on file in our system.
The Rule worked well, it would make the call to our API to detect the existing email and then redirect the user back to the auth0 login page with a message stating they already have an account. The redirect URL from the Rule looks like this:
`https://${domain}/authorize?response_type=code&link=1&linkmessage=${err}&` +
`audience=${audience}&client_id=${configuration.client_id}&${connections}&` +
`username=${email}&redirect_uri=https://${domain}/continue?scope=${scope.replace(
/ /g,
"%2B"
)}`
and the updated URL for the Action is this:
`https://${domain}/authorize?response_type=code&link=1&linkmessage=${err}&` +
`audience=${audience}&client_id=${event.secrets.client_id}&${connections}&` +
`username=${email}&redirect_uri=https://${domain}/continue?scope=${scope.replace(
/ /g,
"%2B"
)}`
which is being passed to
api.redirect.sendUserTo(url);
If I copy/paste this URL into my browser, it directs as expected to the Auth0 login page with the message. However, the Action does not seem to be redirecting the user. Instead, the user is being sent back to our app without all of the necessary data present for their session.
I have read that Actions pause during redirects and continue in the onContinuePostLogin
method of the same Action. When when adding logs to this method, however, it doesn’t appear it is being run after my redirect. When testing this locally, the following steps occur:
- User authorizes our app for a social login
- Logs appear in the Realtime webtask logs extension from the Action saying the user already exists and is being redirected back to login
- The browser redirects to
http://localhost:8080/?code=<somecode>&state=<somestate>
momentarily - The browser then redirects back to
http://localhost:8080
landing the user in the app instead of to the redirect URL provided toapi.redirect.sendUserTo()
which should be the auth0 login page.
Any suggestions on what may be the cause are greatly appreciated. If it is helpful, I still have some Rules in place in the flow prior to this Action, so our system is running a mixture of Rules and Actions.