Closed ITninja04 closed 5 years ago
Hi,
You'll want to create a new Shell.razor file inside the Shared folder with the following code
Shell.razor
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<h1>Sorry</h1>
<p>You're not authorized to reach this page. You may need to log in as a different user.</p>
</NotAuthorized>
<Authorizing>
<p>Please wait...</p>
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<p>Sorry, there's nothing at this address.</p>
</NotFound>
</Router>
Replace App.razor content with the following code
App.razor
@inject Blazor.Auth0.IAuthenticationService authService
@inject Blazor.Auth0.Models.ClientOptions clientOptions
<CascadingAuthenticationState>
<AuthorizeView>
<Authorized>
<Shell></Shell>
</Authorized>
<NotAuthorized>
@if (authService.SessionState == SessionStates.Undefined || clientOptions.RequireAuthenticatedUser)
{
<p>Determining session state, please wait...</p>
}
else
{
<Shell></Shell>
}
</NotAuthorized>
</AuthorizeView>
</CascadingAuthenticationState>
I hope this help.
Thanks so much for that! It totally helped :)
When a user hits the site, the first thing they see is the unauthorized view, then after a few seconds the authorized content comes into view.
For some reason the Authorizing view/route never gets hit.
Any ideas as to what we can do to fix this?