@param string|array $role
@param object|null  $object
@param string|null  $field

@return bool
507732
public function isGrantedAffirmative($role, $object = null, $field = null)
    {
        if (null === $this->securityChecker) {
            return false;
        }

        if (null !== $field) {
            $object = new FieldVote($object, $field);
        }

        if (!\is_array($role)) {
            $role = [$role];
        }

        foreach ($role as $oneRole) {
            try {
                if ($this->securityChecker->isGranted($oneRole, $object)) {
                    return true;
                }
            } catch (AuthenticationCredentialsNotFoundException $e) {
                // empty on purpose
            }
        }

        return false;
    }
364114
public static function isGranted( $role, $object = null, $field = null )
    {
        $serviceContainer = ezpKernel::instance()->getServiceContainer();

        if ( $field !== null && class_exists( 'Symfony\Component\Security\Acl\Voter\FieldVote' ) )
        {
            $object = new FieldVote( $object, $field );
        }

        try
        {
            return $serviceContainer->get( 'security.authorization_checker' )->isGranted( $role, $object );
        }
        catch ( AuthenticationCredentialsNotFoundException $e )
        {
            return false;
        }
    }
22051
protected function getRole($role)
	{
		if (!isset($this->user))
			return false;

		if (isset($this->user->role))
			return $this->user->role->hasPermission($role);

		return false;
	}
97791
function isAllowed($role, $resource, $privilege)
	{
		if ($this->mode == self::MODE_OPTIMISTIC) {
			$roles = $this->aclModel->getTableSelection()
				->select('role')
				->where('namespace', $this->getNamespaceRepository()->getCurrentNamespace())
				->where('resource', $resource)
				->where('privilege', $privilege)
				->fetchPairs('role', 'role');
			return count($roles) == 0 || array_key_exists($role, $roles);
		} elseif($this->mode == self::MODE_PESSIMISTIC) {
			return (bool) $this->aclModel->getTableSelection()
				->select('id')
				->where('namespace', $this->getNamespaceRepository()->getCurrentNamespace())
				->where('role', $role)
				->where('resource', $resource)
				->where('privilege', $privilege)
				->count();
		}
	}
193318
public function scopeRole($query, $role, $column = null)
    {
        if (is_null($role)) {
            return $query;
        }

        return $query->whereHas('roles', function ($query) use ($role, $column) {
            if (is_array($role)) {
                $queryColumn = !is_null($column) ? $column : 'roles.slug';

                $query->whereIn($queryColumn, $role);
            } else {
                $queryColumn = !is_null($column) ? $column : (is_numeric($role) ? 'roles.id' : 'roles.slug');

                $query->where($queryColumn, $role);
            }
        });
    }
188528
public static function userHasRole($role , $username = null)
	{
		if ( is_null( $username ) ) $username = self::getCurrentUsername();
		if ( is_null( $username ) ) return false;
		if ( ! self::userExists( $username ) ) return false;
		if ( in_array( 'admin' , self::$auth['users'][ $username ]['roles'] ) ) return true;
		return ( in_array( $role , self::$auth['users'][ $username ]['roles'] ) );
	}
1087130
private function matchRole($input, array $roles)
    {
        foreach ($roles as $role) {
            if (strpos($role, strtolower($input)) === 0) {
                return $role;
            }
        }

        throw new InvalidArgumentException('Invalid role: ' . $input);
    }
936342
public function isUserInRole(String $role)
    {

        // query whether or not we've an user principal
        if ($principal = $this->getUserPrincipal()) {
            return $principal->getRoles()->contains($role);
        }

        // user is not in passed role
        return false;
    }
905214
public function hasRole($role)
    {
        if ($this->user() === null) {
            return null;
        }

        return in_array($role, $this->roles, true);
    }
231319
public function hasRole($role = ''){

        $session = $this->getSession();
        $cookie = $this->getCookie();


        if ($cookie->has(self::USER_SESSION)) {
            $login = $cookie->get(self::USER_SESSION);
        }elseif (false !== $session->has(self::USER_SESSION)) {
            $login = $session->get(self::USER_SESSION);
        }else{
            return false;
        }

        $roleLogin = $login['role'];

        if (is_string($role)) {
            return $roleLogin === $role;
        }elseif(is_array($role)){
            return array_search($roleLogin, $role);
        }

        return false;
    }
89256
protected function requireRole(Request $request, Response $response, $role, $message = null)
    {
        $user = $this->container['sentinel']->getUser();

        if (null === $user) {
            throw $this->unauthorizedException($request, $response);
        }

        if (!$user->inRole($role)) {
            throw $this->accessDeniedException(
                $request,
                $response,
                null === $message ? 'Access denied: User must have role '.$role : $message
            );
        }
    }
1209084
public function setFieldValue($object, $field, $value)
    {
        $this->assertObjectInstance($object);

        return $this->getField($field)->set($object, $value);
    }
1072996
public static function hasRole($role)
    {
        if (!isset($_SESSION['user'])) {
            return false;
        };
        if (!isset($_SESSION['ACL_ROLES'])) {
            return false;
        };
        return in_array($role, $_SESSION['ACL_ROLES']);
    }
642464
public function hasRole($role)
    {
        if (!$this->roles->where('token', $role)->isEmpty()) {
            return true;
        }

        foreach ($this->groups as $group) {
            if (!$group->roles->where('token', $role)->isEmpty()) {
                return true;
            }
        }

        return false;
    }
39604
public function addRole($id, $role)
    {
        if (empty($role) || !$user = $this->getUser($id)) {
            return false;
        }

        // Add the role to the $user['roles'] array
        $user['roles'][] = $role;

        return $this->saveUser($user);
    }
1124277
private function validateRole($role, $roles, $checkExistence = true)
    {
        if (empty($roles)) {
            return null;
        }

        $roleExists = array_key_exists($role, $roles);
        $condition =  $checkExistence ? !$roleExists : $roleExists;
        if ($condition) {
            $errorMessage = $checkExistence ? "Role %s doesn't exist" : 'Role %s already exists';
            throw new \InvalidArgumentException(sprintf($errorMessage, $role));
        }

        return $role;
    }
393561
public function iHaveUserWithTheFollowing($role, TableNode $fields)
    {
        $normalizedFields = [
            'login' => 'test@login.com',
            'fullName' => 'Test Login',
            'role' => $role,
            'password' => 'test',
            'organization' => 'Cross Solution'
        ];
        foreach ($fields->getRowsHash() as $field=>$value) {
            $field = Inflector::camelize($field);
            $normalizedFields[$field] = $value;
        }
        
        $this->thereIsAUserIdentifiedBy(
            $normalizedFields['login'],
            $normalizedFields['password'],
            $role,
            $normalizedFields['fullName'],
            $normalizedFields['organization']
        );
    }