diff --git a/Shogi.UI/Pages/Authentication.razor b/Shogi.UI/Pages/Authentication.razor index 7d5d1a2..b0dbfe9 100644 --- a/Shogi.UI/Pages/Authentication.razor +++ b/Shogi.UI/Pages/Authentication.razor @@ -1,10 +1,23 @@ @page "/authentication/{action}" @using Microsoft.AspNetCore.Components.WebAssembly.Authentication +@inject NavigationManager navigationManager - + + @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"); + } + } diff --git a/Shogi.UI/Pages/FancyErrorPage.razor b/Shogi.UI/Pages/FancyErrorPage.razor new file mode 100644 index 0000000..f7c74bb --- /dev/null +++ b/Shogi.UI/Pages/FancyErrorPage.razor @@ -0,0 +1,17 @@ +@page "/error" + +
+
+
+

Oops!

+

Something went wrong.

+

+ Return to the home page +

+
+
+
+ +@code { + +} diff --git a/Shogi.UI/Pages/FancyErrorPage.razor.css b/Shogi.UI/Pages/FancyErrorPage.razor.css new file mode 100644 index 0000000..3cb64a4 --- /dev/null +++ b/Shogi.UI/Pages/FancyErrorPage.razor.css @@ -0,0 +1,4 @@ +main { + display: grid; + place-content: center; +} \ No newline at end of file diff --git a/Shogi.UI/Pages/Home/Account/AccountManager.cs b/Shogi.UI/Pages/Home/Account/AccountManager.cs index c48cf13..25ccfcb 100644 --- a/Shogi.UI/Pages/Home/Account/AccountManager.cs +++ b/Shogi.UI/Pages/Home/Account/AccountManager.cs @@ -123,7 +123,7 @@ public class AccountManager else if (platform == WhichAccountPlatform.Microsoft) { await accountState.SetUser(null); - navigation.NavigateToLogout("authentication/logout", "https://lucaserver.space/shogi"); + navigation.NavigateToLogout("authentication/logout"); } } } diff --git a/Shogi.UI/Pages/Home/Api/MsalMessageHandler.cs b/Shogi.UI/Pages/Home/Api/MsalMessageHandler.cs index fe6ad64..81ee759 100644 --- a/Shogi.UI/Pages/Home/Api/MsalMessageHandler.cs +++ b/Shogi.UI/Pages/Home/Api/MsalMessageHandler.cs @@ -11,7 +11,7 @@ namespace Shogi.UI.Pages.Home.Api authorizedUrls: new[] { "https://api.lucaserver.space/Shogi.Api", "https://localhost:5001" }, scopes: new string[] { "api://c1e94676-cab0-42ba-8b6c-9532b8486fff/DefaultScope", - "offline_access", + //"offline_access", }); }