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

**URL:** <https://community.auth0.com/t/auth0-rule-not-working-wanted-to-add-logincount-to-user-profile-in-angular/75323>\
**Category:** Get Help\
**Created:** [December 22, 2021, 10:53am UTC](https://community.auth0.com/t/auth0-rule-not-working-wanted-to-add-logincount-to-user-profile-in-angular/75323 "2021-12-22T10:53:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Merlin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/merlin/32/33431_2.png) [@Merlin](https://community.auth0.com/u/Merlin)\
**Post date:** [December 22, 2021, 10:53am UTC](https://community.auth0.com/t/auth0-rule-not-working-wanted-to-add-logincount-to-user-profile-in-angular/75323/1 "2021-12-22T10:53:22Z")

</div>

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:

```auto
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

```auto
...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

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [December 22, 2021, 3:14pm UTC](https://community.auth0.com/t/auth0-rule-not-working-wanted-to-add-logincount-to-user-profile-in-angular/75323/2 "2021-12-22T15:14:42Z")

</div>

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](https://mynamespace.mycompany.com/loginCounter)’]

John

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 6, 2022, 3:15pm UTC](https://community.auth0.com/t/auth0-rule-not-working-wanted-to-add-logincount-to-user-profile-in-angular/75323/3 "2022-01-06T15:15:07Z")

</div>

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