Base solution for your next web application
Open Closed

When is ClaimsIdentity populated from auth cookie? #5153


User avatar
0
PhilWynn created

Hi,

I have a requirement to add additional claims to ClaimsIdentity when the user logs in. I have worked out how to do this, and all is fine.

The problem I have is when the user enters the system via a persisted cookie. I cannot seem to find anywhere in the code where I can add the additional claims.

I do not want to store these claims within the cookie, as they could potentially change over time. I would simply like to add them every time the user creates a new session (via login or persisted cookie).

Many thanks.


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    The custom value that you added to user's claim is being persisted via the cookie. The only way to change that value is to delete the user's cookie and regenerate it (a kind of logout/login). claims are meant to be not changeable items like user's email, username, birthdate etc... if you have a custom data that must be changed often, I recommend not to use claims but use setting management. Or you can add an extra property on the User entity.