Enhance authorization and authentication handling by optimizing state synchronization from middleware cache, implementing error handling in custom auth, and adding admin audit and system logs pages with filtering and real-time updates.
This commit is contained in:
@@ -78,9 +78,14 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
const checkAndScheduleRefresh = async () => {
|
||||
try {
|
||||
const sessionData = await $fetch<{ user: any; authenticated: boolean }>('/api/auth/session')
|
||||
// Use middleware cache instead of API call
|
||||
const nuxtApp = useNuxtApp()
|
||||
const authState = nuxtApp.payload?.data?.authState
|
||||
const sessionCache = nuxtApp.payload?.data?.['auth:session:cache']
|
||||
|
||||
if (sessionData.authenticated) {
|
||||
const sessionData = authState || sessionCache
|
||||
|
||||
if (sessionData?.authenticated) {
|
||||
// Get the session cookie to extract expiry time
|
||||
const sessionCookie = useCookie('nuxt-oidc-auth')
|
||||
|
||||
@@ -98,6 +103,8 @@ export default defineNuxtPlugin(() => {
|
||||
console.error('[AUTH_REFRESH] Failed to parse session cookie:', parseError)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('[AUTH_REFRESH] No authenticated session found in cache')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[AUTH_REFRESH] Failed to check session:', error)
|
||||
|
||||
Reference in New Issue
Block a user