SDK
SDK Java v2.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

createRestrictedUser #

Create a new restricted user in Kuzzle. This function allows anonymous users to create a "restricted" user with predefined rights.

There is a small delay between user creation and its availability in our search layer (usually a couple of seconds).
That means that a user that was just created may not be immediately returned by the searchUsers function.


createRestrictedUser(id, content, [options], [callback]) #

Arguments Type Description
id string Unique user identifier, will be used as username
content JSON Object A plain JSON object representing the user
options string (Optional) Optional arguments
callback function Callback handling the response

Options #

Filter Type Description Default
queuable boolean Make this request queuable or not true
refresh string If set to wait_for, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above) undefined

Callback response #

Resolves to a User object.

Usage #

Copied to clipboard!
JSONObject content = new JSONObject();
JSONObject newUser = new JSONObject().put("content", content);
JSONObject credentials = new JSONObject()
  .put("local", new JSONObject()
  // The "local" authentication strategy requires a password
  .put("password", "secret password")
  .put("lastLoggedIn", 1494411803));
newUser.put("credentials", credentials);
Options opts = new Options().setReplaceIfExist(true);
kuzzle
  .security
  .createUser("myNewUser", newUser, opts, new ResponseListener<User>() {
    @Override
    public void onSuccess(User user) {
    }
    @Override
    public void onError(JSONObject error) {
    }
  });