How to tell if a user is logged in for the first time?

Hello,

We would like to show some language to a user if they have just created their account and logged in for the first time. Is there a way for us to tell if a user is logging in for the first time during or after the auth callback?

Thanks,
Paul

Within Rules, you can check context.stats.loginsCount===1 and i.e. add a custom claim to your ID token to handle it accordingly on your client side.

For example:

function (user, context, callback) {
  const namespace = 'https://myapp.example.com/';
  context.idToken[namespace + 'is_new'] = (context.stats.loginsCount === 1);
  callback(null, user, context);
}

Similar threads in this forum:

2 Likes

Fantastic, will give that a go. Many thanks!

1 Like

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