createUser #
Creates a new user.
createUser(kuid, body, [options]);
Property | Type | Description |
---|---|---|
kuid | string | User kuid |
body | object | User content & credentials |
options | object | Query options |
body #
The body
property must contain two objects:
content
: Contains the list of profile ids to attach the user to and potential additional information. At least theprofileIds
must be supplied. Any other attribute can be added. Make sure to update the user mapping collection to match your custom attributes.credentials
: Describes how the new administrator can be authenticated. This object must contain one or more properties, named after the target authentication strategy to use. Each one of these properties are objects containing the credentials information, corresponding to that authentication strategy.
Example:
{
content: {
profileIds: [
'default'
],
firstName: 'John',
lastName: 'Doe'
},
credentials: {
local: {
username: 'admin',
password: 'myPassword'
}
}
}
options #
Property | Type (default) | Description |
---|---|---|
queuable | boolean ( true ) | If true, queues the request during downtime, until connected to Kuzzle again |
refresh | boolean ( false ) | If set to wait_for , Kuzzle will not respond until the created user is indexed |
Resolves #
A User
object containing information about the newly created user.
Usage #
try {
const response = await kuzzle.security.createUser('jdoe', {
content: {
profileIds: [ 'default' ]
},
credentials: {
local: {
username: 'jdoe',
password: 'password'
}
}
});
console.log(response);
/*
User {
_id: 'john.doe',
content:,
{ profileIds: [ 'default' ],
firstName: 'John',
lastName: 'Doe',
fullName: 'John Doe',
_kuzzle_info:
{ author: '-1',
createdAt: 1561379086534,
updatedAt: null,
updater: null } } }
*/
} catch (e) {
console.error(e);
}
Edit this page on Github(opens new window)