samples icon indicating copy to clipboard operation
samples copied to clipboard

Azure B2C only issues a new token with updated claims after refreshing the page

Open SoloPlanRR opened this issue 2 years ago • 0 comments
trafficstars

We have a Blazor Webassembly Application that allows user to switch context (have different roles) without entering their credentials. Basically each user has n different contexts assigned to them. Each context defines their role and the data they can access. Example: User is logged in as John Doe and has access to data x. John can swich to context b to have access to y. They are still logged in as John Doe but have a different role (custom claims). They are basically just updating their role (claims). We have a REST Api in place that returns those claims on login, refresh and when the user switches the portal.

This works so far but with the caveat that after switching the portal (and calling Azure B2C) they have to refresh (F5) the page in order to actually get the new token with the new claims.

Is this a cache issue? (I tried to programmatically do the reload but that doesn't work) Are there any options that may need to be changed preventing the immediate update? Can we add a custom handler for this (is there a hook for this/is this a claims transformation)? We redirect to /authentication/login?context=newContext to try upate the claims/token, is this the way to go?

It is odd that it works as intended after a manual refresh but doing it programmatically it doesn't (also avoiding the reload would be better for our customers).

SoloPlanRR avatar Jul 26 '23 16:07 SoloPlanRR