Newer
Older
eShopOnWeb-VerticalFeatureSlices / src / BlazorAdmin / App.razor
@Derek Comartin Derek Comartin on 27 Jul 2021 1 KB Init
<CascadingAuthenticationState>
    <Router AppAssembly="@typeof(Program).Assembly">
        <Found Context="routeData">
            <AuthorizeRouteView RouteData="@routeData"
                                DefaultLayout="@typeof(MainLayout)">
                <NotAuthorized>
                    @if (!context.User.Identity.IsAuthenticated)
                    {
                        <RedirectToLogin />
                    }
                    else
                    {
                        <h2>Not Authorized</h2>
                        <p>
                            You are not authorized to access
                            this resource.

                            <a href="/">Return to eShop</a>
                        </p>
                    }
                </NotAuthorized>
            </AuthorizeRouteView>
        </Found>
        <NotFound>
            <LayoutView Layout="@typeof(MainLayout)">
                <p>Sorry, there's nothing at this address.</p>
            </LayoutView>
        </NotFound>
    </Router>
</CascadingAuthenticationState>