mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 18:18:27 +00:00
* Feat: add integrations access to OAuth apps * Fix: generalize OAuth flow --------- Co-authored-by: Manoj K <saimanoj58@gmail.com>
24 lines
699 B
TypeScript
24 lines
699 B
TypeScript
import { type LoaderFunctionArgs, json } from "@remix-run/node";
|
|
import { oauth2Service } from "~/services/oauth2.server";
|
|
|
|
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|
const url = new URL(request.url);
|
|
const idToken = url.searchParams.get("id_token");
|
|
|
|
if (!idToken) {
|
|
return json(
|
|
{ error: "invalid_request", error_description: "Missing id_token parameter" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
try {
|
|
const userInfo = await oauth2Service.getUserInfoFromIdToken(idToken);
|
|
return json(userInfo);
|
|
} catch (error) {
|
|
return json(
|
|
{ error: "invalid_token", error_description: "Invalid or expired ID token" },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
}; |