Auth added to blazor
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<p>Sorry, there's nothing at this address.</p>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
||||
<NotAuthorized>
|
||||
@{
|
||||
var returnUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
|
||||
|
||||
NavigationManager.NavigateTo($"login?redirectUri={returnUrl}", forceLoad: true);
|
||||
|
||||
}
|
||||
|
||||
</NotAuthorized>
|
||||
<Authorizing>
|
||||
Wait...
|
||||
</Authorizing>
|
||||
</AuthorizeRouteView>
|
||||
</Found>
|
||||
<NotFound>
|
||||
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<p>Sorry, there's nothing at this address.</p>
|
||||
</LayoutView>
|
||||
|
||||
</NotFound>
|
||||
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
||||
Reference in New Issue
Block a user