Mercurial > gemma
view client/src/router.js @ 904:e4b72a199258
New default bottleneck colors
Mainly to make the stroke color one actually selectable in the ui.
In addition the pink does better match the collors used on the ECDIS layer.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 02 Oct 2018 13:34:59 +0200 |
parents | fb39ec3b95a8 |
children | ca628dce90dd |
line wrap: on
line source
import Vue from "vue"; import Router from "vue-router"; import store from "./store"; import { sessionStillActive, toMillisFromString } from "./application/lib/session"; /* facilitate codesplitting */ const Login = () => import("./login/Login.vue"); const Main = () => import("./application/Main.vue"); const Usermanagement = () => import("./usermanagement/Usermanagement.vue"); const Logs = () => import("./logs/logs.vue"); const Systemconfiguration = () => import("./systemconfiguration/systemconfiguration.vue"); Vue.use(Router); const router = new Router({ routes: [ { path: "/login", name: "login", component: Login }, { path: "/usermanagement", name: "usermanagement", component: Usermanagement, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isSysadmin = store.getters["user/isSysAdmin"]; if (!isSysadmin) { next("/"); } else { next(); } } }, { path: "/logs", name: "logs", component: Logs, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isSysadmin = store.getters["user/isSysAdmin"]; if (!isSysadmin) { next("/"); } else { next(); } } }, { path: "/systemconfiguration", name: "systemconfiguration", component: Systemconfiguration, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isSysadmin = store.getters["user/isSysAdmin"]; if (!isSysadmin) { next("/"); } else { next(); } } }, { path: "/", name: "mainview", component: Main, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const expiresFromPastSession = toMillisFromString( localStorage.getItem("expires") ); if (sessionStillActive(expiresFromPastSession)) { store.commit("user/set_user", localStorage.getItem("user")); store.commit("user/set_expires", expiresFromPastSession); store.commit("user/set_roles", localStorage.getItem("roles")); store.commit("user/set_authenticate", true); } else { store.commit("user/clear_auth"); } next(); } }, { path: "*", component: Login } ] }); router.beforeEach((to, from, next) => { const requiresAuth = to.matched.some(record => record.meta.requiresAuth); const loggedIn = store.getters["user/isAuthenticated"]; const expiresFromPastSession = toMillisFromString( localStorage.getItem("expires") ); const authRequired = requiresAuth && !(loggedIn || sessionStillActive(expiresFromPastSession)); if (authRequired) { next("/login"); } else if (!authRequired) { next(); } else { next(); } }); export default router;