Spaces:
Running
Running
File size: 839 Bytes
64d3841 767afa7 3890de7 64d3841 d5559df 767afa7 3890de7 64d3841 3890de7 64d3841 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import { redirect } from "@sveltejs/kit";
import { getOIDCAuthorizationUrl } from "$lib/server/auth";
import { base } from "$app/paths";
import { ALTERNATIVE_REDIRECT_URLS } from "$env/static/private";
export const actions = {
async default({ url, locals, request }) {
const referer = request.headers.get("referer");
let redirectURI = `${(referer ? new URL(referer) : url).origin}${base}/login/callback`;
// TODO: Handle errors if provider is not responding
if (url.searchParams.has("callback")) {
const callback = url.searchParams.get("callback") || redirectURI;
if (ALTERNATIVE_REDIRECT_URLS.includes(callback)) {
redirectURI = callback;
}
}
const authorizationUrl = await getOIDCAuthorizationUrl(
{ redirectURI },
{ sessionId: locals.sessionId }
);
throw redirect(303, authorizationUrl);
},
};
|