feat: refactor/reorganize auth routes
This commit is contained in:
parent
9d64a5beac
commit
50e43bc0c3
7 changed files with 102 additions and 66 deletions
17
app/routes/auth/oidc-callback.ts
Normal file
17
app/routes/auth/oidc-callback.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { LoaderFunctionArgs, data } from '@remix-run/node'
|
||||
import { loadContext } from '~/utils/config/headplane'
|
||||
import { finishOidc } from '~/utils/oidc'
|
||||
|
||||
export async function loader({ request }: LoaderFunctionArgs) {
|
||||
try {
|
||||
const context = await loadContext()
|
||||
if (!context.oidc) {
|
||||
throw new Error('An invalid OIDC configuration was provided')
|
||||
}
|
||||
|
||||
return finishOidc(context.oidc, request)
|
||||
} catch (error) {
|
||||
// Gracefully present OIDC errors
|
||||
return data({ error }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue