Enable debug logging for Keycloak authentication troubleshooting
DEBUGGING: Add comprehensive console logging to track authentication flow ## Changes Made: ### 1. Configuration Updates (nuxt.config.ts) - Temporarily enabled keycloakDebug: true for production - Allows detailed logging to troubleshoot authentication issues ### 2. Enhanced Error Logging (composables/useKeycloak.ts) - Added [KEYCLOAK] prefixed console logs throughout login flow - Enhanced error reporting with message, stack, and name details - Added logging for initialization status and redirect URIs - TypeScript-safe error handling with instanceof checks ## Debug Information Now Available: - Keycloak initialization status - Login function execution tracking - Redirect URI generation details - Authentication state monitoring - Detailed error messages with stack traces This will help identify exactly where the authentication process is failing and provide actionable debugging information in the browser console. Ready for container rebuild and testing.
This commit is contained in:
parent
a2e1067432
commit
c29f64b50b
|
|
@ -124,23 +124,45 @@ export const useKeycloak = () => {
|
|||
}
|
||||
|
||||
const login = async () => {
|
||||
console.log('[KEYCLOAK] Login function called')
|
||||
|
||||
if (!keycloak.value) {
|
||||
console.log('[KEYCLOAK] Keycloak not initialized, initializing now...')
|
||||
await initKeycloak()
|
||||
}
|
||||
|
||||
if (keycloak.value) {
|
||||
try {
|
||||
const baseUrl = getBaseUrl()
|
||||
logDebug('Starting login', { redirectUri: `${baseUrl}/dashboard` })
|
||||
console.log('[KEYCLOAK] Starting login', {
|
||||
redirectUri: `${baseUrl}/dashboard`,
|
||||
keycloakInitialized: !!keycloak.value,
|
||||
keycloakAuthenticated: keycloak.value.authenticated
|
||||
})
|
||||
|
||||
await keycloak.value.login({
|
||||
redirectUri: `${baseUrl}/dashboard`
|
||||
})
|
||||
|
||||
console.log('[KEYCLOAK] Login method completed successfully')
|
||||
} catch (error) {
|
||||
console.error('Login failed:', error)
|
||||
logDebug('Login error', error)
|
||||
console.error('[KEYCLOAK] Login failed:', error)
|
||||
|
||||
if (error instanceof Error) {
|
||||
console.error('[KEYCLOAK] Error details:', {
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name
|
||||
})
|
||||
} else {
|
||||
console.error('[KEYCLOAK] Unknown error type:', error)
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
} else {
|
||||
console.error('[KEYCLOAK] No keycloak instance available for login')
|
||||
throw new Error('Keycloak not available')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ export default defineNuxtConfig({
|
|||
},
|
||||
// Force HTTPS base URL for production
|
||||
baseUrl: "https://client.portnimara.dev",
|
||||
// Enable debug mode for troubleshooting
|
||||
keycloakDebug: process.env.NODE_ENV === 'development',
|
||||
// Enable debug mode for troubleshooting (temporarily enabled for production)
|
||||
keycloakDebug: true,
|
||||
},
|
||||
},
|
||||
vuetify: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue