Protection routes

arthur_usercookies
Arthur VALIN 2 years ago
parent 7a0a4e4204
commit 249df5cfe0

@ -1,6 +1,9 @@
@page "/list"
@using CraftSharp.Models
@if (AuthStateProvider.GetCurrentUser().Roles.Contains(UserRoles.Admin))
{
<h3>@Localizer["Title"]</h3>
<div>
@ -50,3 +53,7 @@
</DisplayTemplate>
</DataGridColumn>
</DataGrid>
}else{
<p>FORBIDDEN !!</p>
}

@ -16,6 +16,9 @@ namespace CraftSharp.Pages
private int totalItem;
[Inject]
public CustomStateProvider AuthStateProvider { get; set; }
[Inject]
public IStringLocalizer<List> Localizer { get; set; }

@ -11,7 +11,6 @@
</div>
</Authorized>
</AuthorizeView>
@AuthStateProvider.GetCurrentUser().UserName;
<div class="openingPanel">
<img src="/Images/chestBottom.png" class="chest chestOpenBottom @openAnim" />
<img src="/Images/chest.png" class="chest chestOpen @openAnim" />

@ -29,6 +29,10 @@ namespace CraftSharp.Shared
protected override async Task OnInitializedAsync()
{
if (AuthStateProvider.GetCurrentUser() == null || !AuthStateProvider.GetCurrentUser().IsAuthenticated)
{
NavigationManager.NavigateTo("/");
}
isAdmin();
}

Loading…
Cancel
Save