You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
53 lines
1.4 KiB
using CraftSharp.Models;
|
|
using CraftSharp.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
|
|
namespace CraftSharp.Shared
|
|
{
|
|
public partial class HeaderLayout
|
|
{
|
|
[Inject]
|
|
public IStringLocalizer<HeaderLayout> Localizer { get; set; }
|
|
|
|
[Inject]
|
|
public CustomStateProvider AuthStateProvider { get; set; }
|
|
|
|
[Inject]
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
[CascadingParameter]
|
|
private Task<AuthenticationState> AuthenticationState { get; set; }
|
|
|
|
private bool isUserAdmin = false;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
isAdmin();
|
|
}
|
|
|
|
void goInscription()
|
|
{
|
|
NavigationManager.NavigateTo("inscription");
|
|
}
|
|
|
|
void goConnexion()
|
|
{
|
|
NavigationManager.NavigateTo("connexion");
|
|
}
|
|
|
|
async public void isAdmin()
|
|
{
|
|
var roles = AuthStateProvider.GetCurrentUser().Roles;
|
|
isUserAdmin = roles.Contains(UserRoles.Admin);
|
|
}
|
|
private async Task LogoutClick()
|
|
{
|
|
await AuthStateProvider.Logout();
|
|
NavigationManager.NavigateTo("/inscription");
|
|
}
|
|
}
|
|
}
|