createRestrictedUser #
Creates a new user in Kuzzle, with a preset list of security profiles.
The list of security profiles attributed to restricted users is fixed, and must be configured in the Kuzzle configuration file.
This method allows users with limited rights to create other accounts, but blocks them from creating accounts with unwanted privileges (e.g. an anonymous user creating his own account).
createRestrictedUser(body, [kuid], [options]);
Property | Type | Description |
---|---|---|
body | object | User content & credentials |
kuid | string | User kuid. If not provided, a random kuid is automatically generated |
options | object | Query options |
body #
The body
property must contain two objects:
content
: User additional information. Can be left empty.credentials
: Describe how the new user 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: {
firstName: 'John',
lastName: 'Doe'
},
credentials: {
local: {
username: 'jdoe',
password: 'password'
}
}
}
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 user is indexed |
Resolves #
A User
object containing information about the newly created user.
Usage #
try {
const response = await kuzzle.security.createRestrictedUser({
content: {
fullName: 'John Doe'
},
credentials: {
local: {
username: 'jdoe',
password: 'foobar'
}
}
}, 'jdoe');
console.log(response);
/*
User {
_id: 'jdoe',
content:,
{ profileIds: [ 'default' ],
fullName: 'John Doe',
_kuzzle_info:
{ author: '-1',
createdAt: 1561379086534,
udpatedAt: null,
updater: null } } }
*/
console.log('User successfully created');
} catch (e) {
console.error(e);
}
Edit this page on Github(opens new window)