Mercurial > gemma
view client/src/router.js @ 150:44a7e27a0816
Added missing translation for loginerror
Loginerror is now translatable
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 02 Jul 2018 12:54:07 +0200 |
parents | 7ba0a77fd679 |
children | 061209505028 |
line wrap: on
line source
import Vue from "vue"; import Router from "vue-router"; import Login from "./views/Login.vue"; import Main from "./views/Main.vue"; import store from "./store"; Vue.use(Router); const router = new Router({ routes: [ { path: "/login", name: "login", component: Login }, { path: "/", name: "mainview", component: Main, meta: { requiresAuth: true } }, { path: "*", component: Login } ] }); router.beforeEach((to, from, next) => { const requiresAuth = to.matched.some(record => record.meta.requiresAuth); const currentUser = store.getters["user/authenticated"]; if (requiresAuth && !currentUser) { next("/login"); } else if (requiresAuth && currentUser) { next(); } else { next(); } }); export default router;