12 lines
293 B
TypeScript
12 lines
293 B
TypeScript
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")
|
|
}
|
|
})
|