Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
In rare cases especially after an update of our Blazor Wasm website with MSAL (Azure B2C) stays stuck on logging-in. It's difficult to reproduce, but I saw it happening on a iPhone with Chrome. What I saw is that the url only consisted of https://xxx.com/authentication/login-callback
resulting in the app being stuck on infinite 'logging-in', because with that url the masl.js libarary only returns operation completed
which is not handled in the Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticatorViewCore<TState>.ProcessLogInCallback
.
I created the following fix by overriding the 'RemoteAuthenticatorView', but would like to get your opinion about the possible risks\implications of this and maybe this will need to be fixed in the original 'RemoteAuthenticationView' aswell.
public sealed class AuthenticatorViewEx : RemoteAuthenticatorView
{
[Inject] internal NavigationManager Navigation { get; set; }
[Inject] internal AuthenticationStateProvider AuthenticationStateProvider { get; set; }
protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
// Fix stuck in login-callback => redirect to home or login
if (Action == RemoteAuthenticationActions.LogInCallback && Navigation.Uri.Contains($"authentication/{RemoteAuthenticationActions.LogInCallback}", StringComparison.OrdinalIgnoreCase))
{
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
if (state.User.Identity is { IsAuthenticated: true })
{
Navigation.NavigateTo(Navigation.BaseUri, false, true);
}
else
{
Navigation.NavigateTo($@"authentication/{RemoteAuthenticationActions.LogIn}");
}
}
}
}
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
6.0(.8)
Anything else?
No response