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

前端 未结 4 534
爱一瞬间的悲伤
爱一瞬间的悲伤 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 05:43

    Comment This Part in Authenticate.php Of app/Http/Middleware

    protected function redirectTo($request)
             {
                 if (! $request->expectsJson()) {
                    return view('admin.auth.login');
    
                 }
             }
    
    0 讨论(0)
  • 2021-01-12 06:01

    The method redirectTo should return an url path, not the Redirect response.

    ...
    protected function redirectTo()
    {
        if(\Auth::user()->hasRole('copy')){
            return '/copy/dashboardCopy';
        }       
    }
    ...
    
    0 讨论(0)
  • 2021-01-12 06:04
    public $redirectTo = '/lender/home';
    
    protected function redirectTo()
    {
        if(\Auth::guard('lender')->check()){
          $this->redirectTo = '/lender/home';
          return $this->redirectTo;
        }
    }
    
    0 讨论(0)
  • 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']);
    }
    }
    
    0 讨论(0)
提交回复
热议问题