From 7837843f829941435be03da712b669189ad72ad0 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 18 Feb 2025 21:16:54 -0600 Subject: [PATCH] Add redirect capability This feature allows the authentication process to redirect to a route passed in the querystring. This allows the /auth route a means of bringing the user to an expected route instead of the main page (root). --- src/routes/auth/+page.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 60431bcec..02746d26e 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -28,6 +28,12 @@ let ldapUsername = ''; + const querystringValue = (key) => { + const querystring = window.location.search; + const urlParams = new URLSearchParams(querystring); + return urlParams.get(key); + }; + const setSessionUser = async (sessionUser) => { if (sessionUser) { console.log(sessionUser); @@ -39,7 +45,9 @@ $socket.emit('user-join', { auth: { token: sessionUser.token } }); await user.set(sessionUser); await config.set(await getBackendConfig()); - goto('/'); + + const redirectPath = querystringValue('redirect') || '/'; + goto(redirectPath); } };