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

Develop #815

Merged
merged 9 commits into from
Aug 1, 2016
Prev Previous commit
Next Next commit
merge fix and additional comments for PR 773, generates and absolute …
…redirect path for usage inside subfolder installations #773
  • Loading branch information
Chris committed Jan 5, 2016
commit 7575c66724d01b8fe9657a3b9eea0540a317b2fb
2 changes: 1 addition & 1 deletion application/controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function login()
// check login status: if true, then redirect user to user/index, if false, then to login form again
if ($login_successful) {
if (Request::post('redirect')) {
Redirect::to(ltrim(urldecode(Request::post('redirect')), '/'));
Redirect::toPreviousViewedPageAfterLogin(ltrim(urldecode(Request::post('redirect')), '/'));
} else {
Redirect::to('user/index');
}
Expand Down
25 changes: 23 additions & 2 deletions application/core/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
*/
class Redirect
{
/**
* To the last visited page before user logged in (useful when people are on a certain page inside your application
* and then want to log in (to edit or comment something for example) and don't to be redirected to the main page).
*
* This is just a bulletproof version of Redirect::to(), redirecting to an ABSOLUTE URL path like
* "http:https://www.mydomain.com/user/profile", useful as people had problems with the RELATIVE URL path generated
* by Redirect::to() when using HUGE inside sub-folders.
*
* @param $path string
*/
public static function toPreviousViewedPageAfterLogin($path)
{
header('location: http:https://' . $_SERVER['HTTP_HOST'] . '/' . $path);
}

/**
* To the homepage
*/
Expand All @@ -16,9 +31,15 @@ public static function home()
}

/**
* To the defined page
* To the defined page, uses a relative path (like "user/profile")
*
* Redirects to a RELATIVE path, like "user/profile" (which works very fine unless you are using HUGE inside tricky
* sub-folder structures)
*
* @see https://github.com/panique/huge/issues/770
* @see https://github.com/panique/huge/issues/754
*
* @param $path
* @param $path string
*/
public static function to($path)
{
Expand Down