Laravel login error 'Header can contain at most one header, newline detected by laravel login'

I am making a custom login for multiple users. Login / logout works fine on first login, but shows this error on second try

ErrorException on line Response.php 339: Header can contain at most one header, new line found "

what could be the reason for this?

+3


source to share


3 answers


I have the same problem. Observing closely, I noticed that the header that is being passed contains not only the newline char, but also the html code. Code for the page just undoing the redirect to the route I wanted to redirect.

My login is being redirected.

/**
 * Where to redirect users after login.
 *
 * @return string
 */
protected function redirectTo()
{
    return redirect()->route((string)\Auth::user()->group->type);
}

      

If there is already a named route for each type of group->.



I have already tried only returning to the route path without any success or any other error message.

[UPDATE] I found a fix here , changed the code to this and it worked:

protected function redirectTo()
{
    // return redirect()->route((string)\Auth::user()->group->type);
    return route(\Auth::user()->group->type);
}

      

+2


source


Try it in LoginController.



public function redirectTo(){

   $user_id = Auth::user()->id;

   $role_manager = User::where('id', $user_id)->value('role');

   if($role_manager == 'manager'){

       return $this->redirectTo = 'dashboard';

   }
}

      

0


source


you must use

return route('admin.dashboard');

      

instant

 return redirect('admin/dashboard');

      

0


source







All Articles