After receiving the token and storing it in both Vue state and local storage, how can I set up a redirect upon authentication?
Currently, the provided code includes a redirect feature, however the redirect does not occur after obtaining the token and there is no token check.
I am looking for assistance on how to validate the token and then redirect to the fullPath. Can anyone help with this?
var Auth = {
loggedIn: false,
login: function () { this.loggedIn = true },
logout: function () { this.loggedIn = false }
}
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth) && !Auth.loggedIn) {
next({
path: '/login',
query: {redirect: '/'}
})
} else {
next()
}
})