Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensuring role claims are available immediately #3

Open
Webreaper opened this issue Sep 2, 2022 · 0 comments
Open

Ensuring role claims are available immediately #3

Webreaper opened this issue Sep 2, 2022 · 0 comments

Comments

@Webreaper
Copy link

Hey Chris, I found what I think is a small bug in this code. It seems that when you first log in, the roles aren't updated in the token/claims, which means that roles don't work properly until the page refreshes or some other activity results in an authenticationStateChanged being flagged. I think this is because MarkUserAsAuthenticated is only parsing out the user claim, rather than processing the full token from the new login to get all of the user and role claims out of it.

Seems like the fix is just to change the method to do this:

    public void MarkUserAsAuthenticated(string email)
    {
        var authState = GetAuthenticationStateAsync();

        NotifyAuthenticationStateChanged( authState );
    }

since GetAuthenticationStateAsync does the full parse of the JWT for all the roles.

I think I saw somebody else raise this issue in a comment or query somewhere, and you mentioned you were going to look into it, but I didn't see a fix. Hopefully this does it for you. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant