onContinuePostLogin not getting called on Post Login Action redirect

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:

  1. User authorizes our app for a social login
  2. Logs appear in the Realtime webtask logs extension from the Action saying the user already exists and is being redirected back to login
  3. The browser redirects to http://localhost:8080/?code=<somecode>&state=<somestate> momentarily
  4. The browser then redirects back to http://localhost:8080 landing the user in the app instead of to the redirect URL provided to api.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.

For anyone who may come across a similar issue, the problem came from a missing await on a call to the apiClient to get an access token. The actions subsequent to the one I was working on were running before the apiClient fetched the token and performed the user lookup, and so the user was directed back to the app before the redirect was occurring in the Action.

1 Like

Hey @cortney.thomas !

Glad you were able to get this sorted and thanks for sharing your solution :slight_smile: :white_check_mark:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.