Escape hatch.

This commit is contained in:
Lucas Morgan
2023-07-06 15:12:57 -05:00
parent 841dbccc29
commit d80ea13b68
2 changed files with 8 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ public class AccountManager
{ {
var state = await authState.GetAuthenticationStateAsync(); var state = await authState.GetAuthenticationStateAsync();
if (state.User?.Identity?.Name == null || state.User?.Identity?.IsAuthenticated == false) if (state?.User?.Identity?.Name == null || state.User?.Identity?.IsAuthenticated == false)
{ {
// Set the login platform so that we know to log in with microsoft after being redirected away from the UI. // Set the login platform so that we know to log in with microsoft after being redirected away from the UI.
await localStorage.SetAccountPlatform(WhichAccountPlatform.Microsoft); await localStorage.SetAccountPlatform(WhichAccountPlatform.Microsoft);
@@ -66,7 +66,7 @@ public class AccountManager
/// <summary> /// <summary>
/// Try to log in with the account used from the previous browser session. /// Try to log in with the account used from the previous browser session.
/// </summary> /// </summary>
/// <returns></returns> /// <returns>True if login succeeded.</returns>
public async Task<bool> TryLoginSilentAsync() public async Task<bool> TryLoginSilentAsync()
{ {
var platform = await localStorage.GetAccountPlatform(); var platform = await localStorage.GetAccountPlatform();

View File

@@ -1,4 +1,5 @@
@inject AccountManager Account @inject AccountManager Account
@inject AccountState AccountState
<div class="my-modal-background"> <div class="my-modal-background">
@@ -26,13 +27,17 @@
} }
else else
{ {
<h1>Welcome to Shogi!</h1> <h1>Welcome to Shogi!</h1>
<div> <div>
<p>How would you like to proceed?</p> <p>How would you like to proceed?</p>
<p> <p>
<button @onclick="Account.LoginWithMicrosoftAccount">Log in</button> <button @onclick="Account.LoginWithMicrosoftAccount">Log in</button>
<button @onclick="Account.LoginWithGuestAccount">Proceed as Guest</button> <button @onclick="Account.LoginWithGuestAccount">Proceed as Guest</button>
@if (AccountState.User != null)
{
/* This is an escape hatch in case user login fails in certain ways. */
<button @onclick="Account.LogoutAsync">Logout</button>
}
</p> </p>
</div> </div>
<p> <p>