feat: Implement user authentication, admin user management, and role-based access control.

This commit is contained in:
Missez 2026-01-16 16:37:16 +07:00
parent 8a2ca592bc
commit 38648581ec
19 changed files with 1762 additions and 514 deletions

View file

@ -1,6 +1,17 @@
export default defineNuxtRouteMiddleware((to, from) => {
// Skip on server side - let client handle auth
if (process.server) {
return;
}
const authStore = useAuthStore();
authStore.checkAuth();
// Restore session if not authenticated
if (!authStore.isAuthenticated) {
authStore.checkAuth();
}
// Check if user is admin
if (!authStore.isAdmin) {
return navigateTo('/login');
}

View file

@ -1,6 +1,22 @@
export default defineNuxtRouteMiddleware((to, from) => {
// Skip on server side - let client handle auth
if (process.server) {
return;
}
// Skip middleware on login page
if (to.path === '/login') {
return;
}
const authStore = useAuthStore();
authStore.checkAuth();
// Restore session if not authenticated
if (!authStore.isAuthenticated) {
authStore.checkAuth();
}
// Check authentication after restore
if (!authStore.isAuthenticated) {
return navigateTo('/login');
}