blob: ce792cb78d491e7d763b7660aea0d08f8dd107aa [file] [log] [blame]
import Vue from 'vue';
import VueRouter from 'vue-router';
//Do not change store or routes import.
//Exact match alias set to support
//dotenv customizations.
import routes from './routes';
import store from '../store';
Vue.use(VueRouter);
const router = new VueRouter({
base: process.env.BASE_URL,
routes,
linkExactActiveClass: 'nav-link--current'
});
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
if (store.getters['authentication/isLoggedIn']) {
next();
return;
}
next('/login');
} else {
next();
}
});
export default router;