Add error page.
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
@page "/authentication/{action}"
|
||||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
|
||||
@inject NavigationManager navigationManager
|
||||
|
||||
<RemoteAuthenticatorView Action="@Action" />
|
||||
<RemoteAuthenticatorView Action="@Action" LogInFailed="LoginFailed">
|
||||
</RemoteAuthenticatorView>
|
||||
@code {
|
||||
[Parameter] public string? Action { get; set; }
|
||||
// https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly.Authentication/src/Models/RemoteAuthenticationActions.cs
|
||||
// https://github.com/dotnet/aspnetcore/blob/7c810658463f35c39c54d5fb8a8dbbfd463bf747/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.cs
|
||||
|
||||
RenderFragment LoginFailed(string message)
|
||||
{
|
||||
Console.WriteLine($"Failed to login because: {message}");
|
||||
if (message.Contains("AADSTS65004", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return builder => navigationManager.NavigateTo("/");
|
||||
}
|
||||
return builder => navigationManager.NavigateTo("/error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user