Created
August 17, 2018 08:51
-
-
Save andreasvirkus/ef757c3c02f07f9b5a608e88620e5934 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.beforeEach((to, from, next) => { | |
if (to.matched.some(record => record.meta.requiresAuth)) { | |
// this route requires auth, check if logged in if not, redirect to login page. | |
const isAuthenticated = false // TODO implement real auth check | |
if (!isAuthenticated) { | |
next({ path: '/login', query: { redirect: to.fullPath } }) | |
} else { | |
next() | |
} | |
} else { | |
next() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment