Add a role to a user.
512601
def add_role_to_user(user, role):
    
    user = _query_to_user(user)
    role = _query_to_role(role)
    if click.confirm(f'Are you sure you want to add {role!r} to {user!r}?'):
        user.roles.append(role)
        user_manager.save(user, commit=True)
        click.echo(f'Successfully added {role!r} to {user!r}')
    else:
        click.echo('Cancelled.')
1190925
public ServerUpdater addRoleToUser(User user, Role role) {
        delegate.addRoleToUser(user, role);
        return this;
    }
992284
def role_admin():
    """"""
    identity = g.identity
    actions = {}
    for action in access.actions.values():
        actions[action.value] = DynamicPermission(action).allows(identity)

    message = 'You are opening a page requiring the "admin-access" permission'
    return render_template("invenio_access/limited.html",
                           message=message,
                           actions=actions,
                           identity=identity)
1343204
protected function addRole()
    {
        if (!$this->isError()) {
            $id = $this->role->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
143825
function addRolePrivilege (access, role, privilege) {
  if (role === true || access[privilege].role === true) {
    access[privilege] = {
      role: true
    }
    return
  }

  access[privilege].role = _.union(access[privilege].role, _.concat(role))
}
1095917
def addUserToRole( dbid, userid, roleid )
      @dbid, @userid, @roleid  = dbid, userid, roleid 

      xmlRequestData = toXML( :userid, @userid ) 
      xmlRequestData << toXML( :roleid, @roleid ) 
      
      sendRequest( :addUserToRole, xmlRequestData )
      
      return self if @chainAPIcalls
      @requestSucceeded
    end
447037
def add_role(role, reason = nil)
      role_ids = role_id_array(role)

      if role_ids.count == 1
        API::Server.add_member_role(@bot.token, @server.id, @user.id, role_ids[0], reason)
      else
        old_role_ids = @roles.map(&:id)
        new_role_ids = (old_role_ids + role_ids).uniq
        API::Server.update_member(@bot.token, @server.id, @user.id, roles: new_role_ids, reason: reason)
      end
    end
821621
def change_user_role(self, user_id, role):
        
        parameters = {
            'role': role
        }

        url = self.TEAM_USERS_ID_URL % user_id

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_params(parameters)

        return connection.patch_request()
330104
public void addUser(String username, Role role) {
        if (StringUtils.isNullOrEmpty(username)) {
            throw new IllegalArgumentException("A username must be specified.");
        }

        if (role == null) {
            throw new IllegalArgumentException("A role must be specified.");
        }

        users.add(new User(username, role));
    }
317739
def add_user_role(self, user, role):
        
        self.project_service.set_auth(self._token_project)
        self.project_service.add_user_role(user, role)
491991
def addUser(self, username, password,
                firstname, lastname,
                email, role):
        """"""
        self._invites.append({
            "username":username,
            "password":password,
            "firstname":firstname,
            "lastname":lastname,
            "fullname":"%s %s" % (firstname, lastname),
            "email":email,
            "role":role
        })
184137
def add_role(self, role, term, start_date=None, end_date=None,
                 **kwargs):
        
        self['roles'].append(dict(role=role, term=term,
                                  start_date=start_date,
                                  end_date=end_date, **kwargs))
618912
def changeUserRole( dbid, userid, roleid, newroleid )
      @dbid, @userid, @roleid, @newroleid = dbid, userid, roleid, newroleid
      
      xmlRequestData = toXML( :userid, @userid )
      xmlRequestData << toXML( :roleid, @roleid )
      xmlRequestData << toXML( :newroleid, @newroleid )
      
      sendRequest( :changeUserRole, xmlRequestData )

      return self if @chainAPIcalls
      @requestSucceeded
    end
705669
def create_role(self, role_name, mount_point='approle', **kwargs):
        

        return self._adapter.post('/v1/auth/{0}/role/{1}'.format(mount_point, role_name), json=kwargs)
211377
def create_role(self, **kwargs):
        """"""

        role = self.role_model(**kwargs)
        return self.put(role)
491838
def add_role(user, roles):
        
        def _add_role(role):
            user_role = UserRole()
            user_role.user_id = user.user_id
            user_role.role_id = role.role_id
            db.session.add(user_role)
            db.session.commit()
        [_add_role(role) for role in roles]
860729
def add_user_role(self, user, role_name):
        """"""

        # For SQL: user.roles is list of pointers to Role objects
        if isinstance(self.db_adapter, SQLDbAdapter):
            # user.roles is a list of Role IDs
            # Get or add role
            role = self.db_adapter.find_first_object(self.RoleClass, name=role_name)
            if not role:
                role = self.RoleClass(name=role_name)
                self.db_adapter.add_object(role)
            user.roles.append(role)

        # For others: user.roles is a list of role names
        else:
            # user.roles is a list of role names
            user.roles.append(role_name)