lib/users.js
function update (client) {
  return function update (realmName, user) {
    return new Promise((resolve, reject) => {
      user = user || {};
      const req = {
        url: `${client.baseUrl}/admin/realms/${realmName}/users/${user.id}`,
        auth: {
          bearer: privates.get(client).accessToken
        },
        json: true,
        method: 'PUT',
        body: user
      };

      request(req, (err, resp, body) => {
        if (err) {
          return reject(err);
        }

        // Check that the status cod
        if (resp.statusCode !== 204) {
          return reject(body);
        }

        return resolve(body);
      });
    });
  };
}
function update (client) {
  return function update (realmName, user) {
    return new Promise((resolve, reject) => {
      user = user || {};
      const req = {
        url: `${client.baseUrl}/admin/realms/${realmName}/users/${user.id}`,
        auth: {
          bearer: privates.get(client).accessToken
        },
        json: true,
        method: 'PUT',
        body: user
      };

      request(req, (err, resp, body) => {
        if (err) {
          return reject(err);
        }

        // Check that the status cod
        if (resp.statusCode !== 204) {
          return reject(body);
        }

        return resolve(body);
      });
    });
  };
}
function update ( client ) { return function update ( realmName , user ) { return new Promise ( ( resolve , reject ) => { user = user || { } ; const req = { url : ` ${ client . baseUrl } ${ realmName } ${ user . id } ` , auth : { bearer : privates . get ( client ) . accessToken } , json : true , method : 'PUT' , body : user } ; request ( req , ( err , resp , body ) => { if ( err ) { return reject ( err ) ; } // Check that the status cod if ( resp . statusCode !== 204 ) { return reject ( body ) ; } return resolve ( body ) ; } ) ; } ) ; } ; }
A function to update a user for a realm
@param {string} realmName - The name of the realm(not the realmID) - ex: master,
@param {object} user - The JSON representation of the fields to update for the user - This must include the user.id field.
@returns {Promise} A promise that resolves.
@example
keycloakAdminClient(settings)
.then((client) => {
client.users.update(realmName, user)
.then(() => {
console.log('success')
})
})
A function to update a user for a realm