Search code examples
c#asp.net-mvc.net-4.0claims-based-identityclaims

Update claims for an loggedon User?


I have more higher level question for updating an onlogged user claims in an ASP.Net 4.8 website.

How should I do it?

  1. If I recreates the claims on every post, then point of using claims seems pointless. So skipped that.
  2. If I store a datetime for latest change on claims and then I check the datetime at everypost. But that feels wrong seems like point 1 but just reading smaller mass each time.
  3. I do a session singleton "publisher/subscriber" (called N1 here) where it stores a change to the users. The user id be posted in the N1 and next time the user loads a page it check to see if it names in N1 and if it then it reloades it claims?

Number 3 seems to be the way to go, but it still feels not right. Any other suggestions?


Solution

  • I solved this with a static class with a threadsafe dictonary that was checked for userId(if it was changed). If it found it needed to reload the user claims and then remove the userid from the threadsafe dictonary.