Bind new query param to callback url

We want to send back a query param in the callback url that indicates that a user signed up during their auth0 flow. I have the basic setup of an auth0 action to check whether that’s the case:

exports.onExecutePostLogin = async (event, api) => {
  let isSignup = event.stats.logins_count === 1;

But there is no clear way to bind this to a query param on the callback.

I don’t think binding to app or user metadata makes a lot of sense here, since this is related to just this explicit interaction.

I don’t want to invoke a custom API, since the logic we want to implement on signup on our side requires the user cookies be present, so basically only makes sense to run during callback.

We can’t just pass this information from the client to auth0, since the user can change from login to signup or vice versa during the auth0 flow itself.

Hi @joseph.pasque,

Have you considered adding this info as a custom claim in the token?

Create Custom Claims

That is definitely an option, however it feels a bit rough to pollute the tokens with a claim that we only plan to use once.

Our current approach actually does nothing on the auth0 end. During the callback endpoint execution, we invoke the management API to get the user details. Included within these details is their logins_count. If that value is 1, we know that this user just signed up.

I wouldn’t suggest doing this. This solution is much more expensive than adding a custom claim to the token.

Custom claims, Actions, and tokens are built to be handle changes on every auth cycle. The management API, however, is not. You will quickly run into management API rate limits if you are making requests against it every time a user authenticates, and you will not be able to scale this type of flow.

Adding a custom claim to the token indicating it is a first login is not unusual.

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