headplane/app/routes/auth/oidc-callback.ts
2025-01-06 08:19:40 +05:30

18 lines
513 B
TypeScript

import { type LoaderFunctionArgs, data } from 'react-router';
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 });
}
}