Actions and pre-user-registration trigger

I am learning Actions and am interested in the pre-user-registration trigger functionality. My end goal is to take action prior to an account getting created in Auth0.

Does this trigger fire when someone tries to login with a oAuth provider for the first time and BEFORE that user identity is saved as a user?

I am not grokking the documentation on what actions and when the trigger occurs.

Thank you!

1 Like

From this documentation, it looks like the action is triggered before the user profile is entered into a database or passwordless connection.

This would not apply to social or enterprise connections.

1 Like

Hi @josiah_devizia,

Thank you for sharing the solution with the rest of the Community!

If you encounter any further questions, please feel free to reach out.

Thank you.

Is there an actions trigger which does fire prior to a oAuth user identity being added as an account/user?

Here is the full list of triggers and flows for actions. I don’t think there is one that meets your criteria. Maybe @rueben.tiow can weigh in, whether this is possible or if a feature request is needed.

1 Like

Yeah I don’t understand how adding a new user identity (creating) when someone is LOGING IN in is a feature and not a bug. I seem to be the minority on this though.

Well in the case that you are using a third party Identity Provider, Auth0 is not creating the user identity on login. They are creating a user profile in Auth0. The identity lives with the third party (social or enterprise connections).

1 Like

Thank you for the clarification. Is there a trigger or other method I can use to before this happens?

You can probably have an action that checks if this is a new profile on their first login.
I would imagine in a post-login action you could check if event.stats.logins_count is 1 (or 0, i’m not sure when it increments).

1 Like

Hi @brett2 and @josiah_devizia,

Thank you both for the responses.

Yes, this would be a great workaround! For clarity, the login count will be 1 because Enterprise or Social users gets added to Auth0 regardless of clicking the “signing up” and “logging in” buttons. Meaning, that the user will always log in both sign-up and log-in flows.

exports.onExecutePostLogin = async (event, api) => {
  if (event.stats.logins_count === 1) {
    //Your logic here
  }
};

I hope this helps!

Please let me know if you have any additional questions.

Thank you.

1 Like