Debugging live-only bug.
This commit is contained in:
@@ -77,7 +77,6 @@ public class AccountManager
|
||||
var platform = await localStorage.GetAccountPlatform();
|
||||
if (platform == WhichAccountPlatform.Guest)
|
||||
{
|
||||
Console.WriteLine($"Try Login Silent - {platform}");
|
||||
var response = await shogiApi.GetToken(WhichAccountPlatform.Guest);
|
||||
if (response != null)
|
||||
{
|
||||
@@ -91,7 +90,6 @@ public class AccountManager
|
||||
}
|
||||
else if (platform == WhichAccountPlatform.Microsoft)
|
||||
{
|
||||
Console.WriteLine($"Try Login Silent - {platform}");
|
||||
var state = await authState.GetAuthenticationStateAsync();
|
||||
if (state.User?.Identity?.Name != null)
|
||||
{
|
||||
|
||||
@@ -2,18 +2,25 @@
|
||||
|
||||
namespace Shogi.UI.Pages.Home.Api
|
||||
{
|
||||
public class CookieCredentialsMessageHandler : DelegatingHandler
|
||||
{
|
||||
public class CookieCredentialsMessageHandler : DelegatingHandler
|
||||
{
|
||||
|
||||
public CookieCredentialsMessageHandler()
|
||||
{
|
||||
}
|
||||
public CookieCredentialsMessageHandler()
|
||||
{
|
||||
}
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);
|
||||
Console.WriteLine("cookie handler: {0}", request.RequestUri);
|
||||
return base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);
|
||||
try
|
||||
{
|
||||
return base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Catch!");
|
||||
return base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace Shogi.UI.Pages.Home.Api
|
||||
|
||||
public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState)
|
||||
{
|
||||
Console.WriteLine("ShogiApi constructor");
|
||||
this.serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
||||
this.accountState = accountState;
|
||||
this.guestHttpClient = clientFactory.CreateClient(GuestClientName);
|
||||
@@ -35,7 +34,7 @@ namespace Shogi.UI.Pages.Home.Api
|
||||
|
||||
public async Task GuestLogout()
|
||||
{
|
||||
var response = await this.guestHttpClient.PutAsync(RelativeUri("User/TestGuestLogout"), null);
|
||||
var response = await this.guestHttpClient.PutAsync(RelativeUri("User/GuestLogout"), null);
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
@@ -99,6 +98,6 @@ namespace Shogi.UI.Pages.Home.Api
|
||||
return HttpClient.PatchAsync(RelativeUri($"Sessions/{name}/Join"), null);
|
||||
}
|
||||
|
||||
private static Uri RelativeUri(string path) => new Uri(path, UriKind.Relative);
|
||||
private static Uri RelativeUri(string path) => new(path, UriKind.Relative);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
<div>
|
||||
<p>How would you like to proceed?</p>
|
||||
<p>
|
||||
<button @onclick="Account.LoginWithMicrosoftAccount">Log in</button>
|
||||
<button @onclick="Account.LoginWithGuestAccount">Proceed as Guest</button>
|
||||
<button @onclick="async () => await Account.LoginWithMicrosoftAccount()">Log in</button>
|
||||
<button @onclick="async () => await Account.LoginWithGuestAccount()">Proceed as Guest</button>
|
||||
@if (AccountState.User != null)
|
||||
{
|
||||
/* This is an escape hatch in case user login fails in certain ways. */
|
||||
|
||||
Reference in New Issue
Block a user