diff --git a/docs/guide/advanced/navigation-guards.md b/docs/guide/advanced/navigation-guards.md index 61d9bf13c..3a99e74cf 100644 --- a/docs/guide/advanced/navigation-guards.md +++ b/docs/guide/advanced/navigation-guards.md @@ -39,7 +39,7 @@ Every guard function receives three arguments: ```js // BAD router.beforeEach((to, from, next) => { - if (!isAuthenticated) next('/login') + if (to.name !== 'Login' && !isAuthenticated) next({ name: 'Login' }) // if the user is not authenticated, `next` is called twice next() }) @@ -48,7 +48,7 @@ router.beforeEach((to, from, next) => { ```js // GOOD router.beforeEach((to, from, next) => { - if (!isAuthenticated) next('/login') + if (to.name !== 'Login' && !isAuthenticated) next({ name: 'Login' }) else next() }) ```