Created
June 18, 2020 11:05
-
-
Save pipethedev/e96b5b4982627150670bb49050fd6217 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 VueRouter from 'vue-router' | |
| import Home from '../views/Home.vue' | |
| import SignIn from '../views/SignIn.vue' | |
| import Dashboard from '../views/Dashboard.vue' | |
| import store from '@/store' | |
| Vue.use(VueRouter) | |
| const routes = [ | |
| { | |
| path: '/', | |
| name: 'Home', | |
| component: Home | |
| }, | |
| { | |
| path: '/signin', | |
| name: 'signin', | |
| component: SignIn | |
| }, | |
| { | |
| path: '/dashboard', | |
| name: 'dashboard', | |
| component: Dashboard, | |
| beforeEnter: (to, from, next) => { | |
| if(!store.getters['auth/authenicated']){ | |
| return next({ | |
| name: 'signin' | |
| }) | |
| } | |
| next() | |
| } | |
| }, | |
| ] | |
| const router = new VueRouter({ | |
| mode: 'history', | |
| base: process.env.BASE_URL, | |
| routes | |
| }) | |
| export default router |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment