cineclub-site/front/middleware/toLogin.global.ts

13 lines
293 B
TypeScript
Raw Permalink Normal View History

2022-12-25 23:52:43 +01:00
import { useAuthStore } from "~/stores/authStore"
export default defineNuxtRouteMiddleware(async (to) => {
if (
!process.server &&
to.meta.layout === "admin" &&
to.name !== "admin-login" &&
!(await useAuthStore().isLogged)
) {
return navigateTo("/admin/login")
}
})