mirror of https://github.com/halo-dev/halo
18 lines
418 B
TypeScript
18 lines
418 B
TypeScript
![]() |
import { useUserStore } from "@/stores/user";
|
||
|
import type { Router } from "vue-router";
|
||
|
|
||
|
export function setupAuthCheckGuard(router: Router) {
|
||
|
router.beforeEach((to, from, next) => {
|
||
|
const userStore = useUserStore();
|
||
|
|
||
|
if (userStore.isAnonymous) {
|
||
|
window.location.href = `/console/login?redirect_uri=${encodeURIComponent(
|
||
|
window.location.href
|
||
|
)}`;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
next();
|
||
|
});
|
||
|
}
|