fixed logout
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router';
|
import { createRouter, createWebHistory, type NavigationGuard, type RouteLocationNormalized, type RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import Admin from '@/pages/Admin.vue';
|
import Admin from '@/pages/Admin.vue';
|
||||||
import Login from '@/pages/Login.vue';
|
import Login from '@/pages/Login.vue';
|
||||||
@@ -19,7 +19,7 @@ declare module 'vue-router' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const routes = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
@@ -80,6 +80,17 @@ const routes = [
|
|||||||
props: true, // so `guid` shows up as a prop
|
props: true, // so `guid` shows up as a prop
|
||||||
meta: { requiresAuth: true }
|
meta: { requiresAuth: true }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/logout',
|
||||||
|
name: 'Logout',
|
||||||
|
meta: { requiresAuth: false },
|
||||||
|
redirect: { name: 'Login' },
|
||||||
|
beforeEnter(_to:RouteLocationNormalized, _from:RouteLocationNormalized, next) {
|
||||||
|
auth.clear()
|
||||||
|
next()
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
|||||||
Reference in New Issue
Block a user