login and auth
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { authService } from "@/services/auth";
|
||||
import { useAuthService } from "@/services/auth";
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router";
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
@@ -34,8 +34,10 @@ const router = createRouter({
|
||||
routes,
|
||||
});
|
||||
|
||||
const { checkLogin } = useAuthService();
|
||||
|
||||
router.beforeEach((to, _from, next) => {
|
||||
const loggedIn = authService.isLoggedIn();
|
||||
const loggedIn = checkLogin();
|
||||
if (to.path !== "/login" && !loggedIn) {
|
||||
return next({ path: "/login" });
|
||||
}
|
||||
|
Reference in New Issue
Block a user