chat-ui / src /routes /login /+page.server.ts
coyotte508's picture
coyotte508 HF staff
🐛 Fix "signin with HF" within space + CSRF (#236)
767afa7 unverified
raw
history blame
559 Bytes
import { redirect } from "@sveltejs/kit";
import { getOIDCAuthorizationUrl } from "$lib/server/auth";
import { base } from "$app/paths";
export const actions = {
default: async function ({ url, locals, request }) {
// TODO: Handle errors if provider is not responding
const referer = request.headers.get("referer");
const authorizationUrl = await getOIDCAuthorizationUrl(
{ redirectURI: `${(referer ? new URL(referer) : url).origin}${base}/login/callback` },
{ sessionId: locals.sessionId }
);
throw redirect(303, authorizationUrl);
},
};