bulletboards/ImageBoardServerApp/Shared/MainLayout.razor

48 lines
1.1 KiB
Text
Raw Normal View History

2023-01-18 12:56:24 +00:00
@inherits LayoutComponentBase
@using ImageBoardServerApp.Auth
@inject AuthenticationStateProvider authStateProvider
@inject NavigationManager navManager
2023-01-18 12:56:24 +00:00
<PageTitle>BulletBoard</PageTitle>
<div class="page">
<div class="sidebar">
<NavMenu/>
</div>
<main>
2023-02-02 07:15:43 +00:00
2023-01-18 12:56:24 +00:00
<div class="top-row px-4">
<a href="/sys/faq">[FAQ]</a>
<a href="/sys/rules">[Rules]</a>
2023-01-18 12:56:24 +00:00
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
@code
{
private string mail { get; set; } = "";
protected override async Task OnInitializedAsync()
{
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
var user = await cauthStateProvder.GetAuthenticationStateAsync();
if (user.User.Identity.IsAuthenticated)
{
mail = user.User.Identity.Name;
}
}
private async Task logout()
{
var customAuthStateProvider = (CustomAuthenticationStateProvider) authStateProvider;
await customAuthStateProvider.UpdateAuthenticationStateAsync(null);
navManager.NavigateTo("/", true);
}
}