How can I update a user's claims after they have logged in using ASP.NET Identity

767 Views Asked by At

I am working on a Blazor web application with ASP.NET Identity added to it.

The account register/login functionality has all been added as MVC out of the box.

After the user has logged in, they interact with the Blazor app.

After they have logged in, they can perform an action which adds a Claim to their user. The Claim is added and I can see it in the ASPNetUserClaims table.

The next time the user logs in, the Claim is available in the Blazor code and the server side code.

However, immediately after adding the Claim (before their next login and for the rest of their session) the Claim is not available by default, e.g. using authState.User.Claims in Blazor, or User.Claims in an ApiController.

I believe this is because the claims are written into the user's JWT token when they login, and saved in their browser.

Is there a way to update the JWT token in the user's browser if they make a request that changes their Claims? Ideally using ASP.NET Identity?

0

There are 0 best solutions below