Returns true if the role of the current user has the given privilege

@param string $privilege
@param boolean $current Checks value for current role (when false for normal role);
@return bool
422315
public function hasPrivilege($privilege, $current = true)
    {
        if (! $this->acl) {
            return true;
        }
        $role = $this->getRole($current);

        return $this->acl->isAllowed($role, null, $privilege);
    }
1278999
function hasRole(rbac, role, cb) {
  if (!this.role) {
    cb(null, false);
    return this;
  }

  // check existance of permission
  rbac.hasRole(this.role, role, cb);
  return this;
}
910423
public function hasPermission($permission)
    {
        $perm_id = $this->getPermissionId($permission);
        $roles = $this->getRolesWithPermission($perm_id);

        foreach ($roles as $role)
            if ($this->hasRole($role))
                return true;

        return false;
    }
582098
public function hasRole()
    {
        if ($this->role instanceof Acl\Role\RoleInterface
            || is_string($this->role)
            || static::$defaultRole instanceof Acl\Role\RoleInterface
            || is_string(static::$defaultRole)
        ) {
            return true;
        }
    
        return false;
    }
1287186
public function hasRole(string $role): bool
    {
        return (null !== $this->roles) ? \in_array($role, $this->roles) : false;
    }
102635
public function grantAccess($roleOrPermission, UserInterface $user = null)
    {
        $user = $user ? : $this->currentUser();

        if (is_array($roleOrPermission) && $this->grantAccessByRoles($roleOrPermission, $user)) {
            return true;
        } else if (is_array($roleOrPermission) && $this->grantAccessByPermissions($roleOrPermission, $user)) {
            return true;
        } else if ($this->grantAccessByRole($roleOrPermission, $user)) {
            return true;
        } else if ($this->grantAccessByPermission($roleOrPermission, $user)) {
            return true;
        }

        return false;
    }
783740
public function isGranted($permission, $context = null)
    {
        $roles = $this->roleService->getIdentityRoles();

        if (empty($roles)) {
            return false;
        }

        if (!$this->rbac->isGranted($roles, $permission)) {
            return false;
        }

        if ($this->hasAssertion($permission)) {
            return $this->assert($this->assertions[(string) $permission], $context);
        }

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

        return false;
    }
377223
public static function hasRole($roles)
    {
        $user = wp_get_current_user();

        if (is_string($roles)) {
            $roles = array($roles);
        }

        if (!array_intersect($roles, $user->roles)) {
            return false;
        }

        return true;
    }
28770
public function hasRole($role)
    {
        if ($role instanceof RoleInterface) {
            $role = $role->getName();
        }

        if (!is_string($role)) {
            throw new InvalidArgumentException(
                'Role argument must be string or an object implemented "Rad\Authorization\Rbac\RoleInterface".'
            );
        }

        return isset($this->roles[$role]);
    }
1069649
private function getRule($role, $resource, $privilege)
    {
        $role = $this->roles->get($role);

        if (is_scalar($resource)) {
            $resource = new Resource($resource);
        } elseif (!$resource instanceof ResourceInterface) {
            throw new \InvalidArgumentException('$resource is expected to be of type string or Gobline\Acl\ResourceInterface');
        }

        if (is_scalar($privilege)) {
            $privilege = new Privilege($privilege);
        } elseif (!$privilege instanceof Privilege) {
            throw new \InvalidArgumentException('$privilege is expected to be of type string or Gobline\Acl\Privilege');
        }

        foreach ($this->rules as $rule) {
            if (!$rule->getRole()->equals($role)) {
                continue;
            }
            if (!$rule->getPrivilege()->equals($privilege) && !$rule->getPrivilege()->equals('*')) {
                continue;
            }
            if (!$rule->getResource()->matches($resource) && (!$rule->getResource() instanceof Resource || !$rule->getResource()->matches('*'))) {
                continue;
            }

            return $rule;
        }

        foreach ($role->getParents() as $role) {
            $rule = $this->getRule($role, $resource, $privilege);
            if ($rule !== null) {
                return $rule;
            }
        }

        return null;
    }
1201343
public static boolean currentUserHasRole(String... roles) {
    if (roles == null || roles.length == 0) return false;

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication != null) {
      Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
      if (authorities == null) throw new IllegalStateException("No user currently logged in");

      for (String role : roles) {
        for (GrantedAuthority grantedAuthority : authorities) {
          if (role.equals(grantedAuthority.getAuthority())) return true;
        }
      }
    }
    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();
		}
	}
235206
public function grantToRole($permission, $role)
    {
        /** @var EloquentRole $roleModel */
        if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
            return false;
        }

        $permissions = is_array($permission) ? $permission : [ $permission ];

        foreach ($permissions as $singlePermission) {
            $this->grantSinglePermissionToRole($singlePermission, $roleModel);
        }

        if ( ! $roleModel->save()) {
            // @codeCoverageIgnoreStart
            return false;
            // @codeCoverageIgnoreEnd
        }

        $this->fireRoleChangeEvent();
        return true;
    }
966783
public function isAllowed($module, $privilege): bool
    {
        if ($privilege) {
            $user = Auth::getIdentity();
            return $user && $user->hasPrivilege($module, $privilege);
        }
        return true;
    }
182526
public static function traceCurrentAbility(string $role, string $permission, bool $granted)
    {
        self::$debug['current_ability'] = [
            'role'       => $role,
            'permission' => $permission,
            'granted'    => $granted,
            ];
    }
274034
public function hasRole($id, $role)
    {
        if (!$user = $this->getUser($id)) {
            return false;
        }

        return in_array($role, $user['roles']);
    }