EDMS/middleware/main.js
2025-05-30 21:08:11 +08:00

14 lines
416 B
JavaScript

export default defineNuxtRouteMiddleware(async (to, from) => {
// Check if user is authenticated
const { data: validateUser } = await useFetch("/api/auth/validate", {
method: "GET",
});
// If user is authenticated, redirect to DMS
if (validateUser.value.statusCode === 200) {
return navigateTo("/dms");
}
// If user is not authenticated, redirect to login
return navigateTo("/login");
});