From 6ae7c7369b511f2b3fc2046499b031a7b78734f6 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 26 Nov 2024 18:49:41 +0000 Subject: [PATCH] fix router --- src/web/router.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/web/router.php b/src/web/router.php index 572e4d9..fab1f32 100644 --- a/src/web/router.php +++ b/src/web/router.php @@ -91,7 +91,10 @@ class Router { if (is_array($redirect)) { $redirect = $redirect['redirect']; } - $redirect = maybe_base64_decode($redirect); + if ($redirect == $this->domain) + $redirect = ''; + if ($redirect != '') + $redirect = maybe_base64_decode($redirect); return $redirect; } @@ -136,7 +139,7 @@ class Router { } http_response_code(303); $session->write_headers(); - header("Location: $redirect"); + header("Location: {$redirect}"); } } @@ -164,7 +167,9 @@ class Router { // redirect them to login http_response_code(303); $redirect = maybe_base64_encode($this->get_redirect()); - header("Location: http://{$this->domain}/login?redirect={$redirect}"); + if ($redirect != '') + $redirect = "?redirect={$redirect}"; + header("Location: http://{$this->domain}/login{$redirect}"); } else { // update session expiry $session->reset_expiry();