Create new layout for pages with authorization checks
This commit is contained in:
22
Hcs.WebApp/Components/Layout/AuthorizedLayout.razor
Normal file
22
Hcs.WebApp/Components/Layout/AuthorizedLayout.razor
Normal file
@ -0,0 +1,22 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@layout MainLayout
|
||||
|
||||
<AuthorizeView Roles="@Roles">
|
||||
<Authorized>
|
||||
<CascadingValue Value="this">
|
||||
@Body
|
||||
</CascadingValue>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<RadzenAlert AllowClose="false" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter">
|
||||
У вас нет прав для доступа к этой странице
|
||||
</RadzenAlert>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
|
||||
@code {
|
||||
public string Roles { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user