@param Guard $guard

@return mixed
553444
private function resolveUser(Guard $guard)
    {
        // if we're logging in using remember token
        // then we must resolve user „manually”
        // to prevent csrf token regeneration

        $usingSession = $guard instanceof SessionGuard;
        $recaller     = $usingSession ? $guard->getRequest()->cookies->get($guard->getRecallerName()) : null;

        if ($usingSession && !is_null($recaller)) {
            list($id, $token) = explode('|', $recaller);
            return $guard->getProvider()->retrieveByToken($id, $token);
        } else {
            return $guard->user();
        }
    }
36860
protected function guardFilter(array $data, array $guard): array
    {
        return empty($guard) ? [] :
            array_filter($data, function ($key) use ($guard) {
                return in_array($key, $guard, true);
            }, ARRAY_FILTER_USE_KEY);
    }
696951
public static function rest($xs, $n = 1, $guard = null)
    {
        if ($guard !== null) {
            $n = 1;
        }
        foreach ($xs as $i => $x) {
            if ($n > 0) {
                $n--;
            } else {
                yield $i => $x;
            }
        }
    }
512505
public function handle($request, Closure $next, $guard = null)
    {
        $locale = $this->determinerManager->determineLocale($request);

        $this->app->setLocale($locale);

        return $next($request);
    }
571919
protected function currentUserInfo($guard = null)
    {
        $response = $this->visit("/_dusk/user/{$guard}");

        return json_decode(strip_tags($response->driver->getPageSource()), true);
    }
26739
public function handle($request, Closure $next, $guard = 'admin')
    {
        config(['auth.defaults.guard' => 'admin']);

        $permissionName = $request->route()->getName();

        if (in_array($permissionName, ['admin.login', 'admin.login.post',
            'admin.password.reset.token', 'admin.password.email.post',
            'admin.password.reset.token', 'admin.password.reset',
        ])) {
            return $next($request);
        }

        if (Auth::guard($guard)->user()->is_super_admin == 1) {
            return $next($request);
        }

        $user = Auth::guard('admin')->user();

        if (!$user->hasPermission($permissionName)) {
            throw new \Exception('User Don\'t have permissions', 401);
        }

        return $next($request);
    }
812554
public function getTokenGuard(Token $token, $guards)
    {
        $providers = GuardChecker::getGuardsProviders($guards);

        // use only guard associated to access token provider
        return $providers->has($token->provider) ? [$providers->get($token->provider)] : [];
    }
708997
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return response()->json(['error' => 'Already authenticated.'], 400);
        }

        return $next($request);
    }
517507
public static function findByName(string $name, $guardName = null): PermissionContract
    {
        $guardName = $guardName ?? Guard::getDefaultName(static::class);

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

        if (! $permission) {
            throw PermissionDoesNotExist::create($name, $guardName);
        }

        return $permission;
    }
450177
function guard(value) {
  return value == null || (Array.isArray(value) && value.length === 0) ? '' : value;
}
675569
public static function rest($xs, $n = 1, $guard = null)
    {
        if ($guard !== null) {
            $n = 1;
        }
        return new \LimitIterator(self::wrapIterator($xs), $n);
    }
302580
public function canBeAuthenticated(Authenticatable $user, $guards)
    {
        $userGuard = AuthConfigHelper::getUserGuard($user);

        return in_array($userGuard, $guards);
    }
635189
function guard($authorizeOfGuardName)
    {
        if (! $this->guards->has($authorizeOfGuardName) )
            throw new \Exception(sprintf('Guard Authorization (%s) Not Registered.', $authorizeOfGuardName));

        $guard = $this->guards->get($authorizeOfGuardName);
        return $guard;
    }
968775
public function getAuth(): ?Guard
    {
        if (!$this->hasAuth()) {
            $this->setAuth($this->getDefaultAuth());
        }
        return $this->auth;
    }
288597
public function hasPermissionTo($permission, $guardName = null): bool
    {
        $permissionClass = $this->getPermissionClass();

        if (is_string($permission)) {
            $permission = $permissionClass->findByName(
                $permission,
                $guardName ?? $this->getDefaultGuardName()
            );
        }

        if (is_int($permission)) {
            $permission = $permissionClass->findById(
                $permission,
                $guardName ?? $this->getDefaultGuardName()
            );
        }

        if (! $permission instanceof Permission) {
            throw new PermissionDoesNotExist;
        }

        return $this->hasDirectPermission($permission) || $this->hasPermissionViaRole($permission);
    }
131513
protected function extractGuard($string)
    {
        $options = Collection::make(explode('|', $string));

        return $options->reject(function ($option) {
            return strpos($option, 'guard:') === false;
        })->map(function ($option) {
            return explode(':', $option)[1];
        })->first();
    }
749032
public function login($userId, $guard = null)
    {
        $guard = $guard ?: config('auth.defaults.guard');

        $provider = Auth::guard($guard)->getProvider();

        $user = Str::contains($userId, '@')
                    ? $provider->retrieveByCredentials(['email' => $userId])
                    : $provider->retrieveById($userId);

        Auth::guard($guard)->login($user);
    }