Checks whether fe_user is authenticated and has given role id

@param int $role
@return bool
960731
public static function hasRoleId($role)
    {
        return (self::isFeUser()
            && self::isAuthenticated()
            && in_array($role, $GLOBALS['TSFE']->fe_user->groupData['uid'])
        );
    }
245882
private function isGranted($role, $object = null): bool
    {
        if (null === $this->securityChecker) {
            return false;
        }

        try {
            return $this->securityChecker->isGranted($role, $object);
        } catch (AuthenticationCredentialsNotFoundException $e) {
            return false;
        }
    }
641367
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('name', $role);
        }

        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->hasRole($r)) {
                    return true;
                }
            }

            return false;
        }

        return !!$role->intersect($this->roles)->count();
    }
1063247
public function hasRole($role, $requireAll = false)
    {
        if ($user = $this->user()) {
            return $user->hasRole($role, $requireAll);
        }

        return false;
    }
123458
public function hasRole($role)
    {
        $roles = array_column($this->roles->toArray(), 'name');
        return array_search($role, $roles) > -1;
    }
1246872
public function iShouldNotBeAbleToLogInAsRole(string $role)
    {
        try {
            $this->iAmLoggedInAsRole($role);
        } catch (ExpectationException $e) {
            // Expectation fulfilled.
            return;
        } catch (RuntimeException $e) {
            // Expectation fulfilled.
            return;
        }

        throw new ExpectationException(
            sprintf(
                '[W802] A user with role "%s" was logged-in succesfully. This should not have happened.',
                $role
            ),
            $this->getSession()->getDriver()
        );
    }
966964
public function hasRoles($roles)
    {
        if (! is_null($this->getUser())) {
            return $this->getUser()->hasRoles($roles);
        }

        return false;
    }
39061
public function addRole($role)
    {
        if ($role instanceof Role) {
            $role = $role->id;
        }

        // We don't want a double up on roles
        if (false !== array_search($role, (array) $this->attributes['roles'])) {
            return false;
        }

        $this->attributes['roles'][] = $role;

        return true;
    }
873894
public function getRole($role)
    {
        $params = [
            'role' => $role,
        ];

        $body = $this->request(self::URI_AUTH_ROLE_GET, $params);
        $body = $this->decodeBodyForFields(
            $body,
            'perm',
            ['key', 'range_end',]
        );
        if ($this->pretty && isset($body['perm'])) {
            return $body['perm'];
        }

        return $body;
    }
1339795
public function hasRole($role)
    {
        if (is_array($role)) {
            return in_array($this->attributes['role'], $role);
        }

        return $this->attributes['role'] == $role;
    }
905214
public function hasRole($role)
    {
        if ($this->user() === null) {
            return null;
        }

        return in_array($role, $this->roles, true);
    }
606803
public function isAll($role)
    {
        foreach ($this->getArrayFrom($role) as $role) {
            if (!$this->hasRole($role)) {
                return false;
            }
        }

        return true;
    }
322445
public function hasRole($role, $user = null)
    {
        $roleName = $role instanceof Role ? $role->getRole() : $role;

        $user = $user ?: $this->getUser();

        if (!($user instanceof UserInterface)) {
            return false;
        }

        if (null === $this->roleHierarchy) {
            return in_array($roleName, $user->getRoles(), true);
        }

        $userRoles = $this->roleHierarchy->getReachableRoles($this->getUserRolesAsObjects($user));
        foreach ($userRoles as $userRole) {
            if ($roleName === $userRole->getRole()) {
                return true;
            }
        }

        return false;
    }
925350
public function checkAccess($role){
		if(!\Yii::$app->user->isGuest)
		{
			if(Yii::$app->user->identity->role == self::$roles[$role])
			{
				return true;
			}
		}
		return false;
	}
288380
protected function processRule($role) {
        if ($role === '*') {
            return true;
        }
        if ($role === '?') {
            return auth()->guest() ?: $this->renderFailure(__('Please Under Guest!'));
        }
        if ($role === '@') {
            return !auth()->guest() ?:
                $this->renderFailure(__('Please Login User!'), 401, 401);
        }
        if ($role === '!') {
            return $this->renderFailure(__('The page not found！'), 404, 404);
        }
        return $this->processCustomRule($role);
    }
286826
public function hasRoleForUser($name, $role)
    {
        $roles = $this->getRolesForUser($name);

        $hasRole = false;
        foreach ($roles as $r) {
            if ($r == $role) {
                $hasRole = true;

                break;
            }
        }

        return $hasRole;
    }
1190327
public function hasRole($role)
    {
        return is_null($this->roles) || in_array($role, $this->roles, true);
    }