Mercurial > gemma
view client/src/router.js @ 691:d643ff60f607
Client: improve style of waterway axis.
* Add label and circle style to waterway axis via WFS.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Thu, 20 Sep 2018 14:33:34 +0200 |
parents | 8e67604d972a |
children | badbc0207418 |
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"); 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: "/", 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;