-
Notifications
You must be signed in to change notification settings - Fork 788
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
redirect issue with checkAuthentication() #681
Comments
Sorry I don't understand the problem to be honest. Can you go into detail what "the url is duplicated" means ? THanks! |
Test it...
L |
That's a problem if you install the script in subfolders only. |
It was a nice improvement to automatically follow the subdirectories by the config, so I tought it will be usefull, if the redirect process fits itself also. But anyway, it's a nice framework, and helps me a lot in my small projects. |
@lkissorban Okay, I see, but this problem only exists when you don't install the framework properly! Usually an application will not have something like "/projects/huge-master/projects/huge-master/" inside the URL. But to be fair, you're right, this is definitly not optimal for people who want to install it inside a subfolder. Hmm, let's put this on the TODO-liste, maybe someone has a really good solution here! Can I ask you: Are there any other problems beside this redirect when using huge in a subfolder (i mean, when the URL has the subfolder inside) ? |
No, it's working fine in a subfolder. |
Here what have I done for this issue, First as you suggest I added base_url to config, 'BASE_URL' => str_replace('public', '', dirname($_SERVER['SCRIPT_NAME'])), I added two function to Redirect Class /**
* To the defined page
*
* @param $path
*/
public static function back($redirect){
header("location: " . Config::get('URL') . ltrim(urldecode(Request::post('redirect')), '/'));
}
/**
* Get current page which you wanted to redirect later
*
* @return $path
*/
public static function get(){
return urlencode(substr($_SERVER['REQUEST_URI'],strlen(Config::get('BASE_URL'))));
} How to use it? Well, first get() will give you url of current page which you will redirect after login or a post request. back() will take this get() value if you want and redirect you to that page. Why have I done this? For simplicity. I don't like to use long length codes over and over again. Here is my Auth class: Redirect::to('login?redirect=' . Redirect::get()); Here is my code in LoginController class: Redirect::back(Request::post('redirect')); |
Thanks, I'll link this issue from the readme troubleshooting section (and close this ticket), so people can find it easier. |
+1 for this simple solution! Seems to have solved the issue for me entirely. To expand slightly for others, in the LoginController class I replaced
with
and in the Auth class replaced
with
|
The redirect is not working after login, as the url is duplicated.
Solution:
in config.php a new line after 'URL' definition:
'BASE_URL' => str_replace('public', '', dirname($_SERVER['SCRIPT_NAME'])),
in Auth.php change the header() line to:
header('location: ' . Config::get('URL') . 'login?redirect=' . urlencode(substr($_SERVER['REQUEST_URI'],strlen(Config::get('BASE_URL')))));
L
The text was updated successfully, but these errors were encountered: