-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Authorization in Admin pages (#436)
- Loading branch information
1 parent
8fdc436
commit b0669af
Showing
5 changed files
with
13 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,11 @@ | ||
@page "/Admin/Index" | ||
@using Microsoft.AspNetCore.Authorization | ||
@* @attribute [Authorize(Roles = "Admin")] *@ | ||
@attribute [Authorize(Roles = "Admin")] | ||
@inject NavigationManager NavigationManager | ||
@layout Admin.Shared.AdminLayout | ||
|
||
<PageTitle>System Administration</PageTitle> | ||
|
||
<h2>Hashtag to watch</h2> | ||
|
||
<TagSearch /> | ||
|
||
@code { | ||
|
||
[CascadingParameter] | ||
private HttpContext HttpContext { get; set; } = default!; | ||
|
||
protected override Task OnInitializedAsync() | ||
{ | ||
var user = HttpContext.User; | ||
if (!user.IsInRole("Admin")) | ||
{ | ||
NavigationManager.NavigateTo("/"); | ||
} | ||
return base.OnInitializedAsync(); | ||
} | ||
|
||
} | ||
<TagSearch /> |
2 changes: 1 addition & 1 deletion
2
src/TagzApp.Blazor/Components/Admin/Pages/ModalCustomization.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/TagzApp.Blazor/Components/Admin/Pages/UiCustomization.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters