Instead of a single login page, I'm using a modal for user login. I want to redirect logged in user to the page where modal form opened.
I tried to modify LoginController
with return Redirect::back();
but it returned with "Header may not contain more than a single header, new line detected".
This is my modified LoginController.php
protected function redirectTo()
{
return Redirect::back();
}
Maybe I'm following completely wrong way to do that. So I'm open for any suggestion. Thanks in advance for answers.
In your App\\Http\\Controllers\\Auth\\LoginController
Override the authenticated
function with this:
protected function authenticated(Request $request, $user) {
return redirect('/'.$request->path());
}
The $request->path()
will retrieve the request origin path.
@Edit to see the owner's comment in another answer
To also get the url parameter, such as /...?p=477
. You can edit your modal authentication form to have this hidden input:
<input type="hidden" name="current_page" value="{{Request::getRequestUri()}}">
In this way, in your App\\Http\\Controllers\\Auth\\LoginController
Override the authenticated
function with this:
protected function authenticated(Request $request, $user) {
return redirect($request['current_page']);
}
Hope this helps
不要执行Redirect::back()
,只需使用redirect('/your_page_where_modal_appears')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.