Add user info header to authentication dropdown
All checks were successful
build-and-deploy / build (push) Successful in 23s
build-and-deploy / deploy (push) Successful in 2s

- Created /api/auth/userinfo endpoint to fetch user data from Authentik headers
- Added userInfo state and fetchUserInfo() function to useAuth composable
- Implemented compact user info header in dropdown with avatar, name, and email
- Avatar shows user initials with gradient background
- Styled with glassmorphism design matching app aesthetic
This commit is contained in:
2025-10-12 03:26:38 -06:00
parent efaf33a4f4
commit 182bfa74c9
3 changed files with 124 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
export default defineEventHandler((event) => {
// Authentik forward-auth pasa información del usuario en headers
const username = getHeader(event, 'x-authentik-username') || 'Usuario'
const email = getHeader(event, 'x-authentik-email') || ''
const name = getHeader(event, 'x-authentik-name') || ''
const uid = getHeader(event, 'x-authentik-uid') || ''
// Retornar información del usuario
return {
username,
email,
name: name || username, // Usar username si no hay name
uid,
initials: getInitials(name || username)
}
})
// Helper para obtener iniciales
function getInitials(name: string): string {
if (!name) return '?'
const parts = name.trim().split(/\s+/)
if (parts.length === 1) {
return parts[0].substring(0, 2).toUpperCase()
}
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase()
}