Debugging live-only bug.
This commit is contained in:
@@ -91,19 +91,4 @@ public class UserController : ControllerBase
|
|||||||
await signOutTask;
|
await signOutTask;
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("TestGuestLogout")]
|
|
||||||
public async Task<IActionResult> TestGuestLogout()
|
|
||||||
{
|
|
||||||
var signOutTask = HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
|
||||||
|
|
||||||
var userId = User?.GetShogiUserId();
|
|
||||||
if (!string.IsNullOrEmpty(userId))
|
|
||||||
{
|
|
||||||
connectionManager.Unsubscribe(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
await signOutTask;
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ public class AccountManager
|
|||||||
var platform = await localStorage.GetAccountPlatform();
|
var platform = await localStorage.GetAccountPlatform();
|
||||||
if (platform == WhichAccountPlatform.Guest)
|
if (platform == WhichAccountPlatform.Guest)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Try Login Silent - {platform}");
|
|
||||||
var response = await shogiApi.GetToken(WhichAccountPlatform.Guest);
|
var response = await shogiApi.GetToken(WhichAccountPlatform.Guest);
|
||||||
if (response != null)
|
if (response != null)
|
||||||
{
|
{
|
||||||
@@ -91,7 +90,6 @@ public class AccountManager
|
|||||||
}
|
}
|
||||||
else if (platform == WhichAccountPlatform.Microsoft)
|
else if (platform == WhichAccountPlatform.Microsoft)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Try Login Silent - {platform}");
|
|
||||||
var state = await authState.GetAuthenticationStateAsync();
|
var state = await authState.GetAuthenticationStateAsync();
|
||||||
if (state.User?.Identity?.Name != null)
|
if (state.User?.Identity?.Name != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,8 +12,15 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);
|
request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);
|
||||||
Console.WriteLine("cookie handler: {0}", request.RequestUri);
|
try
|
||||||
|
{
|
||||||
|
return base.SendAsync(request, cancellationToken);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("Catch!");
|
||||||
return base.SendAsync(request, cancellationToken);
|
return base.SendAsync(request, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
|
|
||||||
public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState)
|
public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ShogiApi constructor");
|
|
||||||
this.serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
this.serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
||||||
this.accountState = accountState;
|
this.accountState = accountState;
|
||||||
this.guestHttpClient = clientFactory.CreateClient(GuestClientName);
|
this.guestHttpClient = clientFactory.CreateClient(GuestClientName);
|
||||||
@@ -35,7 +34,7 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
|
|
||||||
public async Task GuestLogout()
|
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();
|
response.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +98,6 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
return HttpClient.PatchAsync(RelativeUri($"Sessions/{name}/Join"), null);
|
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>
|
<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="async () => await Account.LoginWithMicrosoftAccount()">Log in</button>
|
||||||
<button @onclick="Account.LoginWithGuestAccount">Proceed as Guest</button>
|
<button @onclick="async () => await Account.LoginWithGuestAccount()">Proceed as Guest</button>
|
||||||
@if (AccountState.User != null)
|
@if (AccountState.User != null)
|
||||||
{
|
{
|
||||||
/* This is an escape hatch in case user login fails in certain ways. */
|
/* This is an escape hatch in case user login fails in certain ways. */
|
||||||
|
|||||||
Reference in New Issue
Block a user