Files
TechHelper/TechHelper.Client/Pages/AuthLinks.razor
2025-05-23 19:03:00 +08:00

26 lines
577 B
Plaintext

@inject IAuthenticationClientService AuthenticationClientService
@inject NavigationManager NavigationManager
<AuthorizeView>
<Authorized>
<MudText>
Hello, @context.User.Identity.Name!
</MudText>
<MudButton OnClick="Logout"> LOGOUT </MudButton>
</Authorized>
<NotAuthorized>
<MudButton Class="" Href="Register"> Register </MudButton>
<MudButton Class="" Href="Login"> Login </MudButton>
</NotAuthorized>
</AuthorizeView>
@code {
private async Task Logout()
{
await AuthenticationClientService.LogoutAsync();
NavigationManager.NavigateTo("/");
}
}