replaceUser

var newContent = {
  profileIds: ['admin'],
  firstname: 'My Name Is',
  lastname: 'Jonas'
};


// Using callbacks (NodeJS or Web Browser)
kuzzle
  .security
  .replaceUser("User ID", newContent, function (err, replacedUser) {
    // "replacedUser" is an instance of a User object
  });
JSONObject newContent = new JSONObject()
  .put("profileIds", new JSONArray()
    .put("admin")
  )
  .put("firstname", "My Name Is")
  .put("lastname", "Jonas");

kuzzle
  .security
  .replaceUser("User ID", newContent, new ResponseListener<User>() {
    @Override
    public void onSuccess(User user) {

    }

    @Override
    public void onError(JSONObject error) {

    }
  });
<?php

use \Kuzzle\Kuzzle;
use \Kuzzle\Security\User;

$kuid = 'myUser';
$userDefinition = [
  'profileIds' => ['admin'],
  'firstname' => 'My Name Is',
  'lastname' => 'Jonas'
];

$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();

try {
  $user = $security->replaceUser($kuid, $userDefinition);

  // $user instanceof User
}
catch (ErrorException $e) {

}

Replaces an existing user.


replaceUser(id, content, [options], [callback])

ArgumentsTypeDescription
idstringUnique user identifier
contentJSON ObjectA plain JSON object representing the user, should contain the mandatory profileIds field
optionsstring(Optional) Optional arguments
callbackfunction(Optional) Callback handling the response

Options

FilterTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the Security object to allow chaining.


Callback response

Resolves to an User object