svelte-router
svelte-router copied to clipboard
[Feature Request] Multiple guards per route
Something like this could be handy >>
const routes = [
{
name: '/',
component: Dashboard,
layout: BaseLayout,
guards: [
{ onlyIf: userIsLoggedIn, redirect: '/login' },
{ onlyIf: userHasSelectedOrganization, redirect: '/organizations' },
]
}
]
The execution order define which one is called first, etc.
Make sense?
Hi @jorgegorka, thanks for the great library. Is there a reason you closed this feature request? I just came across it while looking for the exact same behaviour as the OP. Would you accept a PR for such functionality?
Hi @mattdavis90
PRs are more than welcome.
I usually like to put the logic of guards inside my templates instead of the router but I don't have a very strong opinion so If you want to send a PR that supports multiple guards I'll be happy to merge it.