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


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?


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 = '';
  context.idToken[namespace + 'is_new'] = (context.stats.loginsCount === 1);
  callback(null, user, context);

Similar threads in this forum:


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.