Auth0 Rule not working? Wanted to add LoginCount to user Profile in Angular

Hi everyone,

i created a very simple Rule, that is supposed to add the logincount for the specific user after he logs in.
The Rule is as followed:

function addLoginCount(user, context, callback) {
    context.idToken['loginCounter'] =
      context.stats.loginsCount;
  callback(null, user, context);
}

When i subscribe and then print the user in my angular app, i cant see the logins count

...auth.user$.subscribe((user0) => {
        console.log("User0: "+JSON.stringify(user0));

Am i missing anything very elementary here? I just created the rule and as I expect it should be applied from there on automatically?

Cheers and Thanks in advance

Hi @Merlin

Two things:

You can use Realtime Webtask Logs extension (available in the dashboard) and console.log to help debug.

The issue here is that non standard token claims (like ‘loginCounter’) must be namespaced, so it should look something like context.idToken[‘https://mynamespace.mycompany.com/loginCounter’]

John

1 Like

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