Spaces:
Sleeping
Sleeping
Andrew
commited on
Commit
·
e27f529
1
Parent(s):
e89b38f
refactor(auth): simplify OIDC login endpoint using auth helpers
Browse files- src/routes/login/+server.ts +2 -11
src/routes/login/+server.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
| 1 |
import { getOIDCAuthorizationUrl } from "$lib/server/auth";
|
| 2 |
-
import {
|
| 3 |
-
import { config } from "$lib/server/config";
|
| 4 |
|
| 5 |
export async function GET({ request, url, locals }) {
|
| 6 |
-
const
|
| 7 |
-
let redirectURI = `${(referer ? new URL(referer) : url).origin}${base}/login/callback`;
|
| 8 |
|
| 9 |
// TODO: Handle errors if provider is not responding
|
| 10 |
|
| 11 |
-
if (url.searchParams.has("callback")) {
|
| 12 |
-
const callback = url.searchParams.get("callback") || redirectURI;
|
| 13 |
-
if (config.ALTERNATIVE_REDIRECT_URLS.includes(callback)) {
|
| 14 |
-
redirectURI = callback;
|
| 15 |
-
}
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
const authorizationUrl = await getOIDCAuthorizationUrl(
|
| 19 |
{ redirectURI },
|
| 20 |
{ sessionId: locals.sessionId }
|
|
|
|
| 1 |
import { getOIDCAuthorizationUrl } from "$lib/server/auth";
|
| 2 |
+
import { buildRedirectURI } from "$lib/server/authHelpers";
|
|
|
|
| 3 |
|
| 4 |
export async function GET({ request, url, locals }) {
|
| 5 |
+
const redirectURI = buildRedirectURI(request, url);
|
|
|
|
| 6 |
|
| 7 |
// TODO: Handle errors if provider is not responding
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
const authorizationUrl = await getOIDCAuthorizationUrl(
|
| 10 |
{ redirectURI },
|
| 11 |
{ sessionId: locals.sessionId }
|