Laravel 5.3 LoginController - Header may not contain more than a single header, new line detected

前端 未结 4 573
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 05:28

I have a problem when changing the default LoginController redirect after login, I\'m getting an ErrorException in Response.php line 339: Header may not

4条回答
  •  忘掉有多难
    2021-01-12 06:07

    I have just solved it replacing the original code, with

    class LoginController extends Controller
    {
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */
    
    use AuthenticatesUsers;
    
    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo;
    
    protected function redirectTo()
    {
        if(\Auth::user()->hasRole('copy')){
            $this->redirectTo = '/copy/dashboardCopy';
            return $this->redirectTo;
        }       
    }
    
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
    }
    }
    

提交回复
热议问题