-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
I am using the AuthorizeRouteView to serve my routes and redirect to a login page if the user is not authenticated. However, I want to include an additional rule that certain pages (marked by a custom attribute) require the user to have set a certain metadata value, and if they have not, to redirect them to a page where they can set that value. The problem is, once authorization is confirmed, there is no place to add additional redirects, as the page is simply loaded. AuthorizeRouteView only takes child content for NotAuthorized
and Authorizing
, but this doesn't apply.
Describe the solution you'd like
I would like to be able to specify an AfterAuthorized
delegate or RenderFragment that runs immediately before the route is processed. Something like this:
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
<NotAuthorized>
<RedirectToLogin/>
</NotAuthorized>
<AfterAuthorized>
<CheckForCustomRedirect/>
</AfterAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
</Found>
</Router>
Right now, my solution is to make my own subclass of RouteView that reimplements AuthorizeRouteView and does the thing that I want it to do, but AuthorizeRouteView relies on a lot of internal and/or sealed infrastructure, so it's difficult to ensure I've re-implemented everything correctly.
Additional context
No response