diff --git a/application/core/Auth.php b/application/core/Auth.php index 82990ffed..d887880b2 100644 --- a/application/core/Auth.php +++ b/application/core/Auth.php @@ -28,11 +28,7 @@ public static function checkAuthentication() // send the user to the login form page, but also add the current page's URI (the part after the base URL) // as a parameter argument, making it possible to send the user back to where he/she came from after a // successful login - header('location: ' . Config::get('URL') . 'login?redirect=' . urlencode($_SERVER['REQUEST_URI'])); - // to prevent fetching views via cURL (which "ignores" the header-redirect above) we leave the application - // the hard way, via exit(). @see https://github.com/panique/php-login/issues/453 - // this is not optimal and will be fixed in future releases - exit(); + Redirect::to('login?redirect=' . urlencode($_SERVER['REQUEST_URI'])); } } @@ -53,11 +49,7 @@ public static function checkAdminAuthentication() if (!Session::userIsLoggedIn() || Session::get("user_account_type") != 7) { // ... then treat user as "not logged in", destroy session, redirect to login page Session::destroy(); - header('location: ' . Config::get('URL') . 'login'); - // to prevent fetching views via cURL (which "ignores" the header-redirect above) we leave the application - // the hard way, via exit(). @see https://github.com/panique/php-login/issues/453 - // this is not optimal and will be fixed in future releases - exit(); + Redirect::to('login'); } } @@ -71,7 +63,6 @@ public static function checkSessionConcurrency(){ if(Session::isConcurrentSessionExists()){ LoginModel::logout(); Redirect::home(); - exit(); } } } diff --git a/application/core/Controller.php b/application/core/Controller.php index 654daad51..06b0d0d6e 100644 --- a/application/core/Controller.php +++ b/application/core/Controller.php @@ -25,7 +25,7 @@ function __construct() // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature) if (!Session::userIsLoggedIn() AND Request::cookie('remember_me')) { - header('location: ' . Config::get('URL') . 'login/loginWithCookie'); + Redirect::to('login/loginWithCookie'); } // create a view object to be able to use it inside a controller, like $this->View->render(); diff --git a/application/core/Redirect.php b/application/core/Redirect.php index 33756382e..7a35de41b 100644 --- a/application/core/Redirect.php +++ b/application/core/Redirect.php @@ -13,6 +13,9 @@ class Redirect public static function home() { header("location: " . Config::get('URL')); + $data = array('destination' => Config::get('URL')); + new View()->render('_templates/redirect.php', $data); + exit(); } /** @@ -23,5 +26,8 @@ public static function home() public static function to($path) { header("location: " . Config::get('URL') . $path); + $data = array('destination' => Config::get('URL') . $path); + new View()->render('_templates/redirect.php', $data); + exit(); } -} \ No newline at end of file +} diff --git a/application/view/_templates/redirect.php b/application/view/_templates/redirect.php new file mode 100644 index 000000000..8762e619c --- /dev/null +++ b/application/view/_templates/redirect.php @@ -0,0 +1,6 @@ +
Redirecting to $destination); ?>
+