Files
aigen/server/api/auth/login.get.ts
T
TowstyandCursor bc0ea613c1 Add a password-gated private instance mode for xaigen.
Keep Authentik on aigen, isolate library data per instance, and purge Comfy outputs from the desktop after they are saved on the server.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 19:24:00 -05:00

22 lines
757 B
TypeScript

export default defineEventHandler(async (event) => {
if (passwordAuthEnabled()) {
await sendRedirect(event, '/login', 302)
return
}
if (!oidcAuthEnabled()) {
throw createError({ statusCode: 404, statusMessage: 'Auth is not enabled' })
}
const config = useRuntimeConfig()
const state = createOauthState(event)
const redirectUri = `${publicBaseUrl(event)}/api/auth/callback`
const params = new URLSearchParams({
response_type: 'code',
client_id: config.oidcClientId,
redirect_uri: redirectUri,
scope: 'openid email profile',
state
})
const authorize = config.oidcAuthorizeUrl || 'https://auth.carrgarage.com/application/o/authorize/'
await sendRedirect(event, `${authorize}?${params.toString()}`, 302)
})