feat: Implement user authentication, admin user management, and role-based access control.
This commit is contained in:
parent
8a2ca592bc
commit
38648581ec
19 changed files with 1762 additions and 514 deletions
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue