-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Description
Version
3.1.6
Reproduction link
Steps to reproduce
I've implemented the beforeEach
guard from the example:
router.beforeEach((to, from, next) => {
// redirect to the login page if the target location requires authentication
if (to.meta.requiresAuth && !isAuthenticated) next('/login')
else next()
})
This works perfectly fine and redirects the user to the login page when he is not authenticated. When I then try to implement the navigation back to the original requested page as in the example it fails:
// user is not authenticated
await router.push('/profile/dashboard')
// `redirectedFrom` is a RouteLocationNormalized, like `currentRoute` but we are omitting
// most properties to make the example readable
router.currentRoute // { path: '/login', redirectedFrom: { path: '/profile/dashboard' } }
Thank you for shining a little bit of light on this subject. Sorry if this is the wrong place to ask but the official example doesn't show something like this.
What is expected?
After successful logon the user should be navigated to the page he requested in the first place.
What is actually happening?
Don't understand how to get that functionality in the app.
Thank you for your help.
Metadata
Metadata
Assignees
Labels
No labels