Last active
September 30, 2019 23:34
-
-
Save danielschmitz/d37568226ba15ff84e7f74032d139808 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
import Vue from 'vue' | |
import Router from 'vue-router' | |
import store from '../store' | |
Vue.use(Router) | |
const router = new Router({ | |
routes: [ | |
{ | |
path: '/', | |
name: 'home', | |
component: () => import(/* webpackChunkName: "home" */ './views/Home.vue') | |
}, | |
{ | |
path: '/login', | |
name: 'login', | |
component: () => import(/* webpackChunkName: "login" */ './views/Login.vue') | |
}, | |
{ | |
path: '/logout', | |
name: 'logout', | |
meta: { requiresAuth: true }, | |
component: () => import(/* webpackChunkName: "logout" */ './views/Logout.vue') | |
}, | |
{ | |
path: '/afastamento', | |
name: 'afastamento', | |
meta: { requiresAuth: true }, | |
component: () => import(/* webpackChunkName: "cadastro" */ './views/Cadastros/Afastamento/index.vue') | |
} | |
] | |
}) | |
router.beforeEach((to, from, next) => { | |
if (to.matched.some(record => record.meta.requiresAuth) && store.token !== '') return next() | |
return next({ | |
path: '/login', | |
query: { redirect: to.fullPath } | |
}) | |
}) | |
export default router |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment