Files
TechHelper/TechHelper.Client/Pages/AuthLinks.razor
SpecialX e824c081bf change
2025-05-30 12:46:55 +08:00

34 lines
738 B
Plaintext

@inject IAuthenticationClientService AuthenticationClientService
@inject NavigationManager NavigationManager
<MudPaper Class=@Class Style=@Style>
<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>
</MudPaper>
@code {
[Parameter]
public string? Class { get; set; }
[Parameter]
public string? Style { get; set; }
private async Task Logout()
{
await AuthenticationClientService.LogoutAsync();
NavigationManager.NavigateTo("/");
}
}