Проблема заголовка в множественной аутентификации - PullRequest
0 голосов
/ 18 декабря 2018

Я пытаюсь создать несколько пользователей: 1. менеджер 2. сотрудник

, но у меня возникает проблема, связанная с: ErrorException выдается с сообщением «Заголовок не может содержать более одного заголовка, обнаружена новая строка»

Stacktrace:

4 ErrorException в E: \ xamp \ htdocs \ TMS \ vendor \ symfony \ http-foundation \ Response.php: 341

3 заголовка в E:\ xamp \ htdocs \ TMS \ vendor \ symfony \ http-foundation \ Response.php: 341

2 Symfony \ Component \ HttpFoundation \ Response: sendHeaders в E: \ xamp \ htdocs \ TMS \ vendor \ symfony \http-foundation \ Response.php: 375

1 Symfony \ Component \ HttpFoundation \ Ответ: отправьте в E: \ xamp \ htdocs \ TMS \ public \ index.php: 58

0 require_onceв E: \ xamp \ htdocs \ TMS \ server.php: 21

my LoginController.php

<?php

namespace App\Http\Controllers\Auth;
use Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

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 function redirectTo( ) {
    if (Auth::check() && Auth::user()->role == 'manager') {
        return redirect('/home');
    }

    else {
        return redirect('/employee/index');
    }
}

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

мой manager.php

<?php

namespace App\Http\Middleware;
use Auth;
use Closure;

class Manager
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
   function handle($request, Closure $next)
{
    if (Auth::check() && Auth::user()->role == 'manager') {
        return redirest('/home');
    }

    else {
        return redirect('/employee/index');
    }
}
}

мой сотрудник.php

<?php

namespace App\Http\Middleware;
use Auth;
use Closure;

class Employee
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
   function handle($request, Closure $next)
{
    if (Auth::check() && Auth::user()->role == 'employee') {
        return redirect('/employee/index');
    }

    else {
        return redirect('/home');
    }
}


}

1 Ответ

0 голосов
/ 18 декабря 2018

Метод redirectTo должен возвращать путь URL:

/*
LoginController.php
*/
protected function redirectTo( ) {
   if (Auth::check() && Auth::user()->role == 'manager') {
      return '/home';
   }else {
      return '/employee/index';
   }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...