-
- {{ user.name }}
- check_circle
-
+
\ No newline at end of file
diff --git a/client/src/routes.js b/client/src/routes.js
index fa1f340..9c0a412 100644
--- a/client/src/routes.js
+++ b/client/src/routes.js
@@ -1,5 +1,5 @@
-import Vue from 'vue'
import VueRouter from 'vue-router'
+import store from './store'
// Pages
import Index from "~/pages/index-page"
@@ -18,80 +18,84 @@ import Profile from "~/pages/user/profile-page"
// Routes
const routes = [
- {
- path: "*",
- redirect: "/",
- },
- {
- path: '/',
- component: Index,
- },
- {
- path: '/connexion',
- component: Login,
- meta: {
- antiAuthGuard: true
- }
- },
- {
- path: '/inscription',
- component: Register,
- meta: {
- antiAuthGuard: true
- }
- },
- {
- path: '/sorts',
- component: Spells,
- },
- {
- path: '/sorts/:id',
- component: SpellSingle,
- props: true,
- },
- {
- path: '/ecoles',
- component: Schools,
- },
- {
- path: '/ecoles/:id',
- component: SchoolSingle,
- props: true,
- },
- {
- path: '/ages',
- component: Timeline,
- },
- {
- path: '/profil',
- component: Profile,
- props: true,
- meta: {
- authGuard: true,
- }
- },
+ {
+ path: "*",
+ redirect: "/",
+ },
+ {
+ path: '/',
+ component: Index,
+ },
+ {
+ path: '/connexion',
+ component: Login,
+ meta: {
+ loginFilter: true
+ }
+ },
+ {
+ path: '/inscription',
+ component: Register,
+ meta: {
+ loginFilter: true
+ }
+ },
+ {
+ path: '/sorts',
+ component: Spells,
+ },
+ {
+ path: '/sorts/:id',
+ component: SpellSingle,
+ props: true,
+ },
+ {
+ path: '/ecoles',
+ component: Schools,
+ },
+ {
+ path: '/ecoles/:id',
+ component: SchoolSingle,
+ props: true,
+ },
+ {
+ path: '/ages',
+ component: Timeline,
+ },
+ {
+ path: '/profil',
+ component: Profile,
+ props: true,
+ meta: {
+ logoutFilter: true,
+ }
+ },
]
const router = new VueRouter({
- mode: 'history',
- routes,
- linkActiveClass: "",
- linkExactActiveClass: "active",
+ mode: 'history',
+ routes,
+ linkActiveClass: "",
+ linkExactActiveClass: "active",
})
router.beforeEach((to, from, next) => {
- if (to.matched.some(record => record.meta.authGuard)) {
- if (Vue.$cookies.get('U_') == null) {
- next({
- path: '/connexion',
- params: { nextUrl: to.fullPath },
- })
- } else {
- next()
- }
- } else {
- next()
+ if (to.matched.some(record => record.meta.loginFilter)) {
+ if (store.getters.getUserToken) {
+ next({
+ path: '/',
+ });
}
+ next();
+ } else if (to.matched.some(record => record.meta.logoutFilter)) {
+ if (!store.getters.getUserToken) {
+ next({
+ path: '/connexion',
+ });
+ }
+ next();
+ }
+ next();
})
export default router;
\ No newline at end of file