From ed05a9f96c6fc7b5c19c5d0e83924ae2abef7572 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Wed, 31 Jan 2018 10:11:56 +0100 Subject: [PATCH] Fix regression with browser redirection --- helpers/auth.php | 6 +++--- helpers/utils.php | 1 + index.php | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/helpers/auth.php b/helpers/auth.php index a582ba6..efed4cc 100644 --- a/helpers/auth.php +++ b/helpers/auth.php @@ -142,7 +142,7 @@ /** * Log out with redirect * - * @param string $path URL path + * @param string $path URL path (without leading slash) * @return void */ public function logOutWithRedirect($path = "") { @@ -173,11 +173,11 @@ /** * Redirect browser and exit * - * @param string $path Redirect URL path + * @param string $path Redirect URL path (without leading slash) * @return void */ public function exitWithRedirect($path = "") { - $location = str_replace("//", "/", BASE_URL . $path); + $location = BASE_URL . $path; header("Location: $location"); exit(); } diff --git a/helpers/utils.php b/helpers/utils.php index ea13ced..c29dbe0 100644 --- a/helpers/utils.php +++ b/helpers/utils.php @@ -110,6 +110,7 @@ /** * Calculate app base URL + * Returned URL has trailing slash. * * @return string URL */ diff --git a/index.php b/index.php index eb770ae..a863b41 100755 --- a/index.php +++ b/index.php @@ -27,10 +27,10 @@ $auth = new uAuth(); if (!$auth->isAuthenticated() && $auth->isLoginAttempt()) { - $auth->exitWithRedirect("/login.php?auth_error=1"); + $auth->exitWithRedirect("login.php?auth_error=1"); } if (!$auth->isAuthenticated() && uConfig::$require_authentication) { - $auth->exitWithRedirect("/login.php"); + $auth->exitWithRedirect("login.php"); }