showing results for - "vue protected router"
Alessia
18 Aug 2017
1router.beforeEach((to, from, next) => {
2  if (to.matched.some(record => record.meta.requiresAuth)) {
3    // this route requires auth, check if logged in
4    // if not, redirect to login page.
5    if (!auth.loggedIn()) {
6      next({
7        path: '/login',
8        query: { redirect: to.fullPath }
9      })
10    } else {
11      next()
12    }
13  } else {
14    next() // make sure to always call next()!
15  }
16})