Add error page.
This commit is contained in:
@@ -1,10 +1,23 @@
|
|||||||
@page "/authentication/{action}"
|
@page "/authentication/{action}"
|
||||||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
|
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
|
||||||
|
@inject NavigationManager navigationManager
|
||||||
|
|
||||||
<RemoteAuthenticatorView Action="@Action" />
|
<RemoteAuthenticatorView Action="@Action" LogInFailed="LoginFailed">
|
||||||
|
</RemoteAuthenticatorView>
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public string? Action { get; set; }
|
[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/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
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
Shogi.UI/Pages/FancyErrorPage.razor
Normal file
17
Shogi.UI/Pages/FancyErrorPage.razor
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@page "/error"
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h1 class="card-title">Oops!</h1>
|
||||||
|
<p class="card-text">Something went wrong.</p>
|
||||||
|
<p class="card-text">
|
||||||
|
<a href="/">Return to the home page</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
||||||
4
Shogi.UI/Pages/FancyErrorPage.razor.css
Normal file
4
Shogi.UI/Pages/FancyErrorPage.razor.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
main {
|
||||||
|
display: grid;
|
||||||
|
place-content: center;
|
||||||
|
}
|
||||||
@@ -123,7 +123,7 @@ public class AccountManager
|
|||||||
else if (platform == WhichAccountPlatform.Microsoft)
|
else if (platform == WhichAccountPlatform.Microsoft)
|
||||||
{
|
{
|
||||||
await accountState.SetUser(null);
|
await accountState.SetUser(null);
|
||||||
navigation.NavigateToLogout("authentication/logout", "https://lucaserver.space/shogi");
|
navigation.NavigateToLogout("authentication/logout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
authorizedUrls: new[] { "https://api.lucaserver.space/Shogi.Api", "https://localhost:5001" },
|
authorizedUrls: new[] { "https://api.lucaserver.space/Shogi.Api", "https://localhost:5001" },
|
||||||
scopes: new string[] {
|
scopes: new string[] {
|
||||||
"api://c1e94676-cab0-42ba-8b6c-9532b8486fff/DefaultScope",
|
"api://c1e94676-cab0-42ba-8b6c-9532b8486fff/DefaultScope",
|
||||||
"offline_access",
|
//"offline_access",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user