title: The middleware RedirectIfAuthenticated doesn't work
body: <p>I have a problem with middleware <code>RedirectIfAuthenticated</code></p>
  
  <p>When I use this middleware in any controller, the <strong>user connect is not detected</strong> (the user connect is NULL). Namely, I use multiple authentication.</p>
  
  <p><strong>RedirectIfAuthenticated</strong></p>
  
  <pre><code>class RedirectIfAuthenticated
  {
      public function handle($request, Closure $next, $guard = null){
          //dd(Auth::guard($guard)-&gt;check()); // when the user is connected the result is null 
          //dd(Auth::user()); // when the user is connect the result is =&gt; Argument 2 passed to Illuminate\Auth\SessionGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given, called in /Users/diegoruiz/Desktop/app/XXX/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 123
  
  
          if($guard == 'admin' &amp;&amp; Auth::guard($guard)-&gt;check()) {
              return redirect('admin/accueil');
          }else if($guard == 'employer' &amp;&amp; Auth::guard($guard)-&gt;check()){
              return redirect('/accueil');
          } else {
              return $next($request);
          }
      }
  }
  </code></pre>
  
  <p><strong>LoginController</strong></p>
  
  <pre><code>    class LoginController extends Controller{
         use AuthenticatesUsers;
      ...
      public function __construct(){
  
      $this-&gt;middleware('guest')-&gt;except('logout');//It's not working.
      //$this-&gt;middleware('guest:admin')-&gt;except('logout');//It's not working.
  
      }
  ...
      }
  </code></pre>
  
  <p><strong>config/auth.php</strong></p>
  
  <pre><code>&lt;?php
  return [
  
      'defaults' =&gt; [
          'guard' =&gt; 'web',
          'passwords' =&gt; 'users',
      ],
  
      'guards' =&gt; [
          'web' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'users',
          ],
          'api' =&gt; [
              'driver' =&gt; 'token',
              'provider' =&gt; 'users',
          ],
          'admin' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'admin',
          ],
          'admin-api' =&gt;[
              'driver' =&gt; 'token',
              'provider' =&gt; 'admins',
          ],
          'employer'=&gt;[
              'driver' =&gt; 'session',
              'provider' =&gt; 'employers',
          ],
          'employer-api'=&gt;[
              'driver' =&gt; 'token',
              'provider' =&gt; 'employers',
          ],
      ],
  
      'providers' =&gt; [
         'admins'=&gt; [
              'driver' =&gt; 'UtilisateurUserProvider',
              'model' =&gt; App\Admin::class,
          ],
          'employers'=&gt;[
              'driver' =&gt; 'UtilisateurUserProvider',
              'model'=&gt; App\Employer::class
          ]
          // 'users' =&gt; [
          //     'driver' =&gt; 'database',
          //     'table' =&gt; 'users',
          // ],
      ],
  
  
  
      'passwords' =&gt; [
          'users' =&gt; [
              'provider' =&gt; 'users',
              'table' =&gt; 'password_resets',
              'expire' =&gt; 60,
          ],
          'admin' =&gt; [
              'provider' =&gt; 'users',
              'table' =&gt; 'password_resets',
              'expire' =&gt; 60,
          ],
          'employer' =&gt; [
              'provider' =&gt; 'users',
              'table' =&gt; 'password_resets',
              'expire' =&gt; 60,
          ],
  
      ],
  
  ];
  </code></pre>
  
  <p><strong>UtilisateurUserProvider</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Providers;
  
  use Illuminate\Auth\EloquentUserProvider as UserProvider;
  use Illuminate\Contracts\Auth\Authenticatable as UserContract;
  use Illuminate\Contracts\Support\Arrayable;
  use Illuminate\Support\Str;
  
  class UtilisateurUserProvider extends UserProvider{
  
      public function boot()
      {
          //
      }
  
      public function register(){
          //
      }
  
      public function retrieveByCredentials(array $credentials)
      {
          if (empty($credentials) ||
              (count($credentials) === 1 &amp;&amp;
                  array_key_exists('mdp', $credentials))) {
              return;
          }
  
          // First we will add each credential element to the query as a where clause.
          // Then we can execute the query and, if we found a user, return it in a
          // Eloquent User "model" that will be utilized by the Guard instances.
          $query = $this-&gt;createModel()-&gt;newQuery();
  
          foreach ($credentials as $key =&gt; $value) {
              if (Str::contains($key, 'uti_mdp')) {
                  continue;
              }
              if (is_array($value) || $value instanceof Arrayable) {
                  $query-&gt;whereIn($key, $value);
              } else {
                  $query-&gt;where($key, $value);
              }
          }
  
          return $query-&gt;first();
      }
  
      public function validateCredentials(UserContract $user, array $credentials){
  
          $plain = $credentials['mdp'];
          return $this-&gt;hasher-&gt;check($plain, $user-&gt;getAuthPassword());
      }
  
  }
  </code></pre>
  
  <p><strong>Kernel</strong> </p>
  
  <pre><code>class Kernel extends HttpKernel
  {
      protected $middleware = [
          \App\Http\Middleware\CheckForMaintenanceMode::class,
          \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
          \App\Http\Middleware\TrimStrings::class,
          \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
          \App\Http\Middleware\TrustProxies::class,
      ];
  
  
      protected $middlewareGroups = [
          'web' =&gt; [
              \App\Http\Middleware\EncryptCookies::class,
              \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
              \Illuminate\Session\Middleware\StartSession::class,
              // \Illuminate\Session\Middleware\AuthenticateSession::class,
              \Illuminate\View\Middleware\ShareErrorsFromSession::class,
              \App\Http\Middleware\VerifyCsrfToken::class,
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
  
          'api' =&gt; [
              'throttle:60,1',
              'bindings',
          ],
      ];
      protected $routeMiddleware = [
          'auth' =&gt; \Illuminate\Auth\Middleware\Authenticate::class,
          'auth.basic' =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
          'bindings' =&gt; \Illuminate\Routing\Middleware\SubstituteBindings::class,
          'cache.headers' =&gt; \Illuminate\Http\Middleware\SetCacheHeaders::class,
          'can' =&gt; \Illuminate\Auth\Middleware\Authorize::class,
          'guest' =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class,
          'signed' =&gt; \Illuminate\Routing\Middleware\ValidateSignature::class,
          'throttle' =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class,
          'entrepriseDatabase' =&gt; \App\Http\Middleware\SetEntrepriseDatabase::class,
      ];
  }
  </code></pre>
  
  <p>when I use <code>Auth::user()</code> in view I have this error</p>