Files
eShopOnWeb/src/BlazorAdmin/Shared/MainLayout.razor
Cédric Michel 8f55b1b56a manage conflict (generic way) use toast to show error (#588)
* manage conflict (generic way) use toast to show error

* fix httpservice after merge conflict, adapt to use new repository
2021-10-25 17:32:07 -04:00

42 lines
1.1 KiB
Plaintext

@inject AuthenticationStateProvider AuthStateProvider
@inject IJSRuntime JSRuntime
@inherits BlazorAdmin.Helpers.BlazorLayoutComponent
<AuthorizeView Roles=@BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS>
<div class="sidebar">
<NavMenu />
</div>
</AuthorizeView>
<div class="main">
<div class="top-row px-4">
<a href="https://github.com/dotnet-architecture/eShopOnWeb" target="_blank" class="ml-md-auto">About eShopOnWeb</a>
</div>
<div class="content px-4">
<Toast></Toast>
@Body
</div>
</div>
@code
{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
if (authState.User == null)
{
await new Route(JSRuntime).RouteOutside("/Identity/Account/Login");
}
CallRequestRefresh();
}
await base.OnAfterRenderAsync(firstRender);
}
}