createRestrictedUser

var userContent = {
  content: {
  },
  credentials: {
    local: {
      // The "local" authentication strategy requires a password
      password: 'secretPassword',
      lastLoggedIn: 1494411803
    }
  }
};


// Using callbacks (NodeJS or Web Browser)
kuzzle
  .security
  .createRestrictedUser('myuser', userContent, options, function(error, response) {
    // result is a User object
  });

// Using promises (NodeJS)
kuzzle
  .security
  .createRestrictedUserPromise('myuser', userContent, options)
  .then((response) => {
    // result is a User object
  });
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) {

    }
  });
<?php

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

$kuid = 'myUser';
$userDefinition = [
    'content' => [
    ],
    'credentials' => [
      'local' => [
        // The "local" authentication strategy requires a password
        'password' => 'secretPassword',
        'lastLoggedIn' => 1494411803
      ]
    ]
  ];

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

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

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

}

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


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

ArgumentsTypeDescription
idstringUnique user identifier, will be used as username
contentJSON ObjectA plain JSON object representing the user
optionsstring(Optional) Optional arguments
callbackfunctionCallback handling the response

Options

FilterTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Callback response

Resolves to a User object.