Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geozak redirection handling #749

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions application/core/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
}
}

Expand All @@ -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');
}
}

Expand All @@ -71,7 +63,6 @@ public static function checkSessionConcurrency(){
if(Session::isConcurrentSessionExists()){
LoginModel::logout();
Redirect::home();
exit();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/core/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 7 additions & 1 deletion application/core/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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();
}
}
}
6 changes: 6 additions & 0 deletions application/view/_templates/redirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="container">
<h1>Redirecting, please wait.</h1>
<div class="box">
<p>Redirecting to <?php echo htmlentities($this->$destination); ?></p>
</div>
</div>