Corrige la deconnexion du compte joueur

This commit is contained in:
2026-04-15 21:42:40 +02:00
parent 1d18a070e5
commit 655637072c
2 changed files with 8 additions and 25 deletions

View File

@@ -42,7 +42,7 @@
<strong>@DisplayName</strong>
<span>@DisplayMeta</span>
</div>
<button class="button ghost small" type="button" @onclick="LogoutAsync" disabled="@IsSubmitting">Se deconnecter</button>
<a class="button ghost small" href="api/auth/logout/browser">Se deconnecter</a>
</div>
}
else
@@ -89,7 +89,7 @@
<strong>@DisplayName</strong>
<span>@DisplayMeta</span>
</div>
<button class="button ghost small" type="button" @onclick="LogoutAsync" disabled="@IsSubmitting">Se deconnecter</button>
<a class="button ghost small" href="api/auth/logout/browser">Se deconnecter</a>
</div>
}
else
@@ -395,29 +395,6 @@
}
}
private async Task LogoutAsync()
{
if (IsSubmitting)
{
return;
}
IsSubmitting = true;
FormError = null;
CloseMobileMenu();
try
{
await Http.PostAsync("api/auth/logout", null);
AuthenticationStateProvider.SetAnonymous();
await RefreshAuthenticationStateAsync();
}
finally
{
IsSubmitting = false;
}
}
private void HandleAuthenticationStateChanged(Task<AuthenticationState> authenticationStateTask)
=> _ = InvokeAsync(RefreshAuthenticationStateAsync);

View File

@@ -291,6 +291,12 @@ app.MapPost("/api/auth/logout", async Task<IResult> (HttpContext httpContext) =>
return TypedResults.Ok(AuthSessionResponse.FromUser(new ClaimsPrincipal(new ClaimsIdentity())));
});
app.MapGet("/api/auth/logout/browser", async Task<IResult> (HttpContext httpContext) =>
{
await httpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return TypedResults.Redirect("/index.html");
});
app.Run();
static AdminUserSummaryResponse MapAdminSummary(AdminIdentityUser identity, UserProfileResponse? profile)