[Vuejs]-Vuejs laravel authentication page blocking

0👍

add a new meta key requiresNotAuth for login and register routes then change beforeEach content like this

if (to.matched.some(record => record.meta.requiresAuth)) {

    if (!store.getters.isAuthenticated) {
        next({name: 'login'})
    } else {
        next()
    }
} 
else if (to.matched.some(record => record.meta.requiresNotAuth)) {

    if (store.getters.isAuthenticated) {
        next({name: 'home'})
    } 
    else {
        next()
    }
} 
else {
    next() // make sure to always call next()!
}

Leave a comment