Get auth request by guard
@param   string  $guard  Web / Api
@return Illuminate\Database\Eloquent\Model
972372
public function authRequest($guard = null)
    {
        return is_null($guard) ? request()->user() ?? request()->user('api') : request()->user($guard);
    }
1322942
public function handle($request, Closure $next, $guard = null)
    {
        if (TriggerHelper::shouldWizardBeTriggered()) return $this->redirectToWizard();

        return $next($request);
    }
274917
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('login');
            }
        }

        return $next($request);
    }
807593
public function handle($request, Closure $next, $guard = null)
    {
        $this->guard = $guard;

        $response = $next($request);

        if ($this->shouldReceiveFreshToken($request, $response)) {
            $response->withCookie($this->cookieFactory->make(
                $request->user($this->guard)->getKey(), $request->session()->token()
            ));
        }

        return $response;
    }
343073
public function login($userId, $guard = null)
    {
        $model = $this->modelForGuard(
            $guard = $guard ?: config('auth.defaults.guard')
        );

        $user = str_contains($userId, '@')
            ? (new $model)->where('email', $userId)->first()
            : (new $model)->find($userId);

        Auth::guard($guard)->login($user);
    }
1246058
public static function getGuardsProviders($guards)
    {
        return collect($guards)->mapWithKeys(function ($guard) {
            return [GuardChecker::defaultGuardProvider($guard) => $guard];
        });
    }
1353787
public function ifCan(string $ability, $params = null, $guard = null)
    {
        $this->hideCallbacks->push(function () use ($ability, $params, $guard) {
            return ! optional(auth()->guard($guard)->user())->can($ability, $params);
        });

        return $this;
    }
545149
public function handle($request, Closure $next, $guard = null, $field = null)
    {
        $ipsAuth = env('BASIC_AUTH_IP', '');
        $ipsAuth = explode(',', $ipsAuth);


        if (env('BASIC_AUTH', false) == true)
        {
            if (empty($ipsAuth) || !in_array($request->ip(), $ipsAuth))
            {
                return $this->auth->guard($guard)->basic() ?: $next($request);
            }

        }

        return $next($request);
    }
1172622
public function user($guard = null)
    {
        $user = Auth::guard($guard)->user();

        return $user ? [
            'className' => get_class($user),
            'id'        => $user->getAuthIdentifier(),
        ] : [];
    }
746835
protected function extendAuthGuard()
    {
        $this->app['auth']->extend('jwt', function ($app, $name, array $config) {
            $guard = new JWTGuard(
                $app['tymon.jwt'],
                $app['auth']->createUserProvider($config['provider']),
                $app['request']
            );

            $app->refresh('request', $guard, 'setRequest');

            return $guard;
        });
    }
1310953
public static function userModel()
    {
        $guard = self::authDriver();

        return collect(config('auth.guards'))
            ->map(function ($guard) {
                return config("auth.providers.{$guard['provider']}.model");
            })->get($guard);
    }
824661
protected function getUserModelFromDefaultGuard($config)
    {
        if (is_null($guard = $config->get('auth.defaults.guard'))) {
            return null;
        }

        if (is_null($provider = $config->get("auth.guards.{$guard}.provider"))) {
            return null;
        }

        return $config->get("auth.providers.{$provider}.model");
    }
1309533
protected function authenticate($request, array $guards)
    {
        if (empty($guards)) {
            $guards = [null];
        }

        foreach ($guards as $guard) {
            if ($this->auth->guard($guard)->check()) {
                return $this->auth->shouldUse($guard);
            }
        }

        throw new AuthenticationException(
            'Unauthenticated.', $guards, $this->redirectTo($request)
        );
    }
84061
public function handle($request, Closure $next, $guard = null)
    {
        // Query string parameters
        if (in_array($request->method(), static::RELEVANT_METHODS_QUERY)) {
            $this->processParamBag($request->query);
        }

        // Input parameters
        if (in_array($request->method(), static::RELEVANT_METHODS_BODY)) {
            $this->processParamBag($request->request);

            if ($request->isJson()) {
                $this->processParamBag($request->json());
            }
        }

        return $next($request);
    }
195670
public function protect($protect = null)
    {
        if ($protect === null) {
            return $this->_protect;
        }
        $this->_protect = $protect;

        return $this;
    }
1214786
public static function findByName(string $name, $guardName = null): RoleContract
    {
        $guardName = $guardName ?? config('auth.defaults.guard');

        $role = static::where('name', $name)->where('guard_name', $guardName)->first();

        if (!$role) {
            throw RoleDoesNotExist::create($name);
        }

        return $role;
    }
659070
public function retrieveByCredentials(array $credentials)
    {
        // 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->createUserModel()->newQuery();

        foreach ($credentials as $key => $value) {
            if (!Str::contains($key, 'password')) {
                $query->where($key, $value);
            }
        }

//        return $query->first();

        $user = $query->first();

        // If the user was not found in the local database, and LDAP authentication
        // is enabled, and the option is set to automatically create new accounts
        // on first login, create the user and return it. Otherwise return what
        // we found, which could be a user or null.
        if (
             is_null($user) &&
             Settings::get('eloquent-ldap.enabled') &&
             Settings::get('eloquent-ldap.create_accounts')
           ) {
            $user = $this->createUserFromLDAP($credentials['username']);
        }

        return $user;
    }