Kyr
Kyr
CC#
Created by yusuff on 9/1/2024 in #help
udemy course advice related to C# , .net
Also, FYI, A lot of Udemy courses are stolen/plagiarised - I avoid it like the plague and try to find the original course authors to support them.
26 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
I have absolutely no idea why this makes a difference ... the default GetAuthenticationStateAsync() is just calling the GetAuthenticatedUser() under the hood anyway so it should produce the same end result... but here we are
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Virtually the same code, just in a different method and I just return the ClaimsPrincipal now instead of the AuthenticationState
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Instead of overriding GetAuthenticationStateAsync() I've changed to overriding GetAuthenticatedUser() instead.
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
FIXED IT! 🥳
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
base.GetAuthenticatedUser() is getting the user directly from JSInterop Still getting the log...
info: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] ### We are authenticated: False
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
@Crdl Swapped this:
var authState = await base.GetAuthenticationStateAsync();
var user = authState.User;
var authState = await base.GetAuthenticationStateAsync();
var user = authState.User;
for this:
var user = await base.GetAuthenticatedUser();
var user = await base.GetAuthenticatedUser();
Which bypasses the caching in the private GetUser() method of the base class. Same issue 😦
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
So on re-loading the page either manually or from a redirect back into the app it's a brand new instance of the wasm app so it should be empty the first time through
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
It's just a private field
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
But the cache isn't persisting anywhere
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
It needs to inherit the RemoteAuthenticationService or the OIDC stuff doesn't work
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Which should do the same as if I reload the page. Yet reloading the page causes it to suddenly see the correct authentication
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
But then I don't get how... because using OIDC the user is redirected away from the Blazor app to the OIDC provider to log in, then redirected back to the app after logging in. Shouldn't that mean that the Blazor app is re-bootstrapped when the user lands back on it?
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Because without my custom provider it would still be doing that
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Yeah, I see. So a bug in Blazor then?
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Not sure how it can be if I'm overriding GetAuthenticationStateAsync()
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
It's so frustrating because I can see Blazor's potential... yet it roadblocks me at every turn
49 replies
CC#
Created by Kyr on 8/12/2024 in #help
Blazor Web Assembly (stand alone) - [Authorize] Attribute not recognising roles straight after login
Already had to abandon the .NET 8 InteractiveAuto style Server + Wasm way of doing things because it just doesn't work with remote auth when you need client components to make authenticated requests to an external API... now having different auth problems with pure wasm.
49 replies