createUser #
Create a new user in Kuzzle.
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 returned by the
searchUsers
function at first. createUser(id, user, [options], [callback]) #
Arguments | Type | Description |
---|---|---|
id | string | Unique user identifier |
user | JSON Object | A plain JSON object representing the user (see below) |
options | string | (Optional) Optional arguments |
callback | function | Callback handling the response |
refresh | string | If set to wait_for , Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) |
The user
object to provide must have the following properties:
content
(JSON object): user global properties- This object must contain a
profileIds
properties, an array of strings listing the security profiles to be attached to the new user - Any other property will be copied as additional global user information
- This object must contain a
credentials
(JSON object): a description of how the new user can identify themselves on Kuzzle- Any number of credentials can be added, each one being an object with name equal to the authentication strategy used to authenticate the user, and with the login data as content.
- If this object is left empty, the user will be created in Kuzzle but the will not be able to login.
Options #
Filter | Type | Description | Default |
---|---|---|---|
queuable | boolean | Make this request queuable or not | true |
Callback Response #
Returns a User object.
Usage #
var user = {
content: {
// A "profileIds" field is required to bind a user to existing profiles
profileIds: ['admin'],
// Additional information may be provided
firstname: 'John',
lastname: 'Doe'
},
credentials: {
// Authentication strategy to use
"local": {
// The necessary information to provide vary,
// depending on the chosen authentication strategy
"username": "jdoe",
"password": "secret password"
}
}
};
var options = {};
// Using callbacks (NodeJS or Web Browser)
kuzzle
.security
.createUser('myuser', user, options, function(error, response) {
// result is a User object
});
// Using promises (NodeJS)
kuzzle
.security
.createUserPromise('myuser', user, options)
.then(response => {
// result is a User object
});
Edit this page on Github(opens new window)