From 526c5e2f4d14f599c4468b9a463088fb1a4142a7 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Thu, 10 Jul 2025 15:28:48 +0200 Subject: [PATCH] Respect redirect when user is already logged in --- svelte/src/login/Router.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/svelte/src/login/Router.svelte b/svelte/src/login/Router.svelte index ff31962..c467309 100644 --- a/svelte/src/login/Router.svelte +++ b/svelte/src/login/Router.svelte @@ -28,7 +28,14 @@ onMount(async () => { user.username !== "" ) { console.debug("User is already logged in, redirecting to user dashboard") - window.location.href = "/user" + + let login_redirect = params.get("redirect") + if (typeof login_redirect === "string" && login_redirect.startsWith("/")) { + console.debug("redirecting user to requested path", login_redirect) + window.location.href = window.location.protocol+"//"+window.location.host+login_redirect + } else { + window.location.href = "/user" + } } })