Files
seguidorDeLotes/nuxt4-app/server/routes/auth/authentik.get.ts
josedario87 3de76369c0
All checks were successful
build-and-deploy / build (push) Successful in 31s
build-and-deploy / deploy (push) Successful in 3s
Fix OAuth authentication route
- Add missing import for oauthAuthentikEventHandler
- Remove default placeholder URLs in nuxt.config.ts
- Fixes 404 error on /auth/authentik endpoint
2025-10-11 17:30:14 -06:00

36 lines
924 B
TypeScript

import { oauthAuthentikEventHandler } from '../../utils/oauth-authentik'
/**
* OAuth Authentik Login Handler
* Ruta: /auth/authentik
*
* Este endpoint inicia el flujo OAuth con Authentik
*/
export default oauthAuthentikEventHandler({
config: {
emailRequired: true
},
async onSuccess(event, { user, tokens }) {
// Guardar información del usuario en la sesión
await setUserSession(event, {
user: {
id: user.id,
email: user.email,
name: user.name || user.preferred_username,
username: user.preferred_username,
picture: user.picture,
groups: user.groups || []
},
loggedInAt: Date.now()
})
// Redirigir al dashboard después del login
return sendRedirect(event, '/')
},
async onError(event, error) {
console.error('Authentik OAuth error:', error)
return sendRedirect(event, '/error?message=auth_failed')
}
})