- Fixed my revert hahaha :)

This commit is contained in:
Alexis
2020-12-18 20:34:47 +01:00
parent 0587656ba6
commit fa945e45c9
6 changed files with 215 additions and 235 deletions

View File

@@ -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;