feat: Implement dashboard layout with navigation and role-based access, enhance authentication middleware to clear cache only on actual auth errors, and update expenses page metadata for authorization checks
This commit is contained in:
@@ -45,12 +45,16 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
||||
console.log(`[MIDDLEWARE] Retrying auth check (attempt ${retries + 1})`)
|
||||
},
|
||||
onResponseError({ response }) {
|
||||
// Clear cache on auth errors
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
console.log('[MIDDLEWARE] Auth error detected, clearing cache')
|
||||
// Clear cache only on actual auth errors, not 404s or other errors
|
||||
if (response.status === 401) {
|
||||
console.log('[MIDDLEWARE] Unauthorized error detected, clearing cache')
|
||||
sessionManager.clearCache();
|
||||
delete nuxtApp.payload.data?.authState;
|
||||
} else if (response.status === 403) {
|
||||
console.log('[MIDDLEWARE] Forbidden error detected, partial cache clear')
|
||||
// Don't clear cache on 403 as user is authenticated but lacks permissions
|
||||
}
|
||||
// Ignore 404s and other errors - they're not authentication issues
|
||||
}
|
||||
}) as any;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user