Auth0 Home Blog Docs

Unable to retrieve loginsCount or logins_count.



I am using Lock V.10 embedded login with Angular 5 to authenticate with “Username-Password-Database” connection. And I want to be able to set up some rules on user registration, but for some reason my context.stats is totally empty.

Before I started using lock embedded login I was using “hosted page login” and it was all working, i was getting all context.stats and login data.

I even enabled google-auth2 as a provider for my lock embedded login, then i got all my stats.

Why is that?


Can you clarify the following; you mention that it worked before you started using Lock and the hosted login page (HLP), however, if you’re using Lock v10 in an Angular application then I’m assuming you’re using Lock embedded in the client application which would mean you were not using HLP.




I mean that when i used HLP i was getting all stats and login data. But now that i moved to lock embedded i dont get that information anymore.


Thanks for confirming that; I was able to reproduce the situation and this seems to be an issue, however, there may be other alternatives for your exact situation so I’ll provide more information as an answer.


As I mentioned in the comments I was able to reproduce the situation either when using Lock embedded in a client application (aka cross-origin authentication) or when using the prompt=none option in the request (aka silent authentication).

As you mentioned the context.stats.loginsCount per the reference documentation should be available in rules so as far as I’m aware this is a bug; I reported the issue internally and can provide an update here when I have more information.

Having said that, with regards to your actual scenario there may be other alternatives. For example, you can run custom code upon a database user registration process by leveraging the pre-user-registration hook.


Thanks for answering!
Ive had the idea of working around it by adding some custom fields to the user_metadata but i really don’t wanna go that way. Hopefully we will get this way working.



To be honest, a flag in app_metadata given user_metadata can be changed by end-user themselves it’s a nice option when you have something you have to do once for each user and it is not optional. You don’t want to couple that logic with login counts as it would be overloading the meaning of a value that should really just be used as a count.


Any new status?



The issue was reviewed and a fix provided, but it still needs to go through the deployment pipeline so unless something abnormal happens and deploys need to be delayed then the fix should be available soon (hours or next days).


@jmangelo GREAT! it works now. I think i deserve a auth0 t-shirt for this bug report :wink:


@jmangelo GREAT! it works now. I think i deserve a auth0 t-shirt for this bug report :wink:


Thanks for your bug report! We have some exciting new changes coming to our Auth0 Community in the near future, and we look forward to sharing them with you!


Ur welcome, looking forward for the changes. Regards,