Verify if user is in role

        :param: role: role to verify against
        :return: if user is in role
        :exception: LTIException if role is unknown
515685
def is_role(self, role):
        
        log.debug("is_role %s", role)
        roles = self.session['roles'].split(',')
        if role in LTI_ROLES:
            role_list = LTI_ROLES[role]
            # find the intersection of the roles
            roles = set(role_list) & set(roles)
            is_user_role_there = len(roles) >= 1
            log.debug(
                "is_role roles_list=%s role=%s in list=%s", role_list,
                roles, is_user_role_there
            )
            return is_user_role_there
        else:
            raise LTIException("Unknown role {}.".format(role))
620565
def _get_roles_query(self, session, identifier):
        
        return (session.query(Role).
                join(role_membership_table, Role.pk_id == role_membership_table.c.role_id).
                join(User, role_membership_table.c.user_id == User.pk_id).
                filter(User.identifier == identifier))
297887
def role= role
      raise ArgumentError, '#add_role takes a single role String or Symbol as the argument' if !role || role.kind_of?(Array)
      self.roles = role
    end
393212
def remove_role_from_user(self, user, role):
        
        rv = False
        user, role = self._prepare_role_modify_args(user, role)
        if role in user.roles:
            rv = True
            user.roles.remove(role)
            self.put(user)
        return rv
27985
def is_admin(self, roles):
        """"""
        for r in roles:
            if r in self.admin_roles:
                return True
        return False
814917
def deny_role(role):
    """"""
    def processor(action, argument):
        db.session.add(
            ActionRoles.deny(action, argument=argument, role_id=role.id)
        )
    return processor
1233309
def is_admin(self):
        
        for ur in self.roleusers:
            if ur.role.code == 'admin':
                return True

        return False
410981
def get_role(self, role):
        
        role = AuthGroup.objects(role=role, creator=self.client).first()
        return role
388219
public function hasRole($role = "general")
	{
        $roleModel = new \erdiko\users\models\Role;
        $roleEntity = $roleModel->findByName($role);
        if (empty($roleEntity)) {
            throw  new \Exception("Error, role {$role} not found.");
        }
        $result = $this->_user->getRole() == $roleEntity->getId();

		return $result;
	}
667762
public function userHasRole(string $role): bool
    {
        $user = $this->getUser();
        
        if($user->hasRole($role))
            return true;
        
        if (null === $userRoles = $user->getRoles())
            return false;
        
        foreach ($userRoles as $userRole) {
            try {
                if(\in_array($role, $this->getRoles($userRole)))
                    return true;                
            } catch (UndefinedRoleException $e) {
                continue;
            }
        }
        
        return false;
    }
731532
def add_role(self, role):
        
        schema = RoleSchema()
        ok = schema.process(role)
        if not ok or not role.id:
            err = 'Role must be valid and saved before adding to user'
            raise x.UserException(err)

        self.__roles.append(role)
1018702
def require_user_roles(*roles):
    
    def wrapper(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            if ext.user_authenticated():
                if not ext.flask_login.current_user.has_any_roles(*roles):
                    return abort(403)
            else:
                return abort(401)
            return f(*args, **kwargs)
        return wrapped
    return wrapper
485695
function roleOrSelf (role) {
        if (!_.isNumber(role)) {
            role = roles[role.toUpperCase()];
        }

        return function validateRoleOrSelf (kontx, next) {
            var userPrivLevel = roles[kontx.user.role.toUpperCase()],
                passedInUserId = kontx.args[0],
                err = createError(strings.group('codes').forbidden, strings.group('errors').user_privileges_exceeded);

            //If user object passed in instead of a string then parse.
            if (!_.isUndefined(kontx.args[0]._id)) {
                passedInUserId = kontx.args[0]._id;
            }

            //If user has enough priviliges then keep going
            if (userPrivLevel <= parseInt(role, 10) || kontx.user._id.toString() === passedInUserId.toString()) {
                next();
                return;
            }

            next(err);
        };
    }
702255
def requires_roles(roles):
    
    def inner(f):
        def is_available_here(context):
            return bool(roles.intersection(context.obj.current_roles))

        def is_available(context):
            result = is_available_here(context)
            if result and hasattr(f, 'is_available'):
                # We passed, but we're wrapping another test, so ask there as well
                return f.is_available(context)
            return result

        @wraps(f)
        def wrapper(self, *args, **kwargs):
            add_auth_attribute('login_required', True)
            if not is_available_here(self):
                abort(403)
            return f(self, *args, **kwargs)

        wrapper.requires_roles = roles
        wrapper.is_available = is_available
        return wrapper
    return inner
1240765
def get_role(self, request: Request):
        
        idr = request.identifier
        return self._get_role(idr)
641690
def has_role(self, role):
        '''
        
        '''
        return self.roles and any([re.search(role, our_role, re.I)
                                   for our_role in self.roles])
136864
def get_role(self, role):
        
        uri = "OS-KSADM/roles/%s" % utils.get_id(role)
        resp, resp_body = self.method_get(uri)
        role = Role(self, resp_body.get("role"))
        return role