1
0
Fork 0
mirror of https://github.com/miawinter98/just-short-it.git synced 2024-11-14 21:39:53 +00:00
just-short-it/Components/Pages/Logout.razor

20 lines
637 B
Plaintext

@page "/logout"
@using Microsoft.AspNetCore.Authentication
@using Microsoft.AspNetCore.Authentication.Cookies
@inject IHttpContextAccessor HttpContextAccessor;
@inject NavigationManager Navigation;
<PageTitle>Logout - Just Short It</PageTitle>
<p class="text-xl text-error">How did you get here?</p>
@code {
protected override async Task OnInitializedAsync() {
var context = HttpContextAccessor.HttpContext;
if (context is null) throw new ArgumentException("HttpContext");
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
Navigation.NavigateTo("/", true);
}
}