Skip to content

Instantly share code, notes, and snippets.

@rayfranco
Created September 16, 2020 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayfranco/139c676e27300e894311da430b98f567 to your computer and use it in GitHub Desktop.
Save rayfranco/139c676e27300e894311da430b98f567 to your computer and use it in GitHub Desktop.
router.beforeEach((to, from, next) => {
const requiresAuth = to.matched.some(record => {
return record.meta.requiresAuth
})
if (requiresAuth && !store.$data.isRegistered) {
next('/login')
} else {
next()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment