C
C#8mo ago
UltraWelfare

❔ Blazor and Auth - Identity

I'm using Blazor Hybrid (closer to Blazor WASM) for a desktop app therefore I've made my own custom "AuthenticationStateProvider" to specify my own logic. As far as it seems like I can get the AuthenticationState which includes the ClaimsPrincipal alongside its Identity and claims. I've put the account's username and id inside claims but they seem to only receive string. It's a bit cumbersome to use claims to get the id, and then cast it to int (since int is my id type). Is there any better way to do it ? I was thinking of getting my model directly from my custom authentication state provider (I have a variable _currentUser set), but i don't know if that's a good idea
2 Replies
JakenVeina
JakenVeina8mo ago
I would probably create an AuthenticationService that parses the relevant claims you're interested in, and caches them
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.