createFirstAdmin #
Creates a Kuzzle administrator account, only if none exist.
Future<KuzzleUser> createFirstAdmin(
String uid, Map<String, dynamic> body,
{bool? reset})
Property | Type | Description |
---|---|---|
kuid | String | Administrator kuid |
body | Map<String, dynamic> | Administrator content & credentials |
reset | bool? ( null ) | If true, restricted permissions are applied to anonymous and default roles |
body #
The body
property must contain two Map<String, dynamic>
:
content
: Administrator additional information. Can be left empty. Any other attribute can be added. Make sure to update the user mapping collection to match your custom attributes.credentials
: Describe 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': {
'firstName': 'John',
'lastName': 'Doe'
},
'credentials': {
'local': {
'username': 'admin',
'password': 'myPassword'
}
}
}
Return #
A User
object containing information about the newly created administrator.
Usage #
final result = await kuzzle.security.createFirstAdmin(
'admin',
{
'content': {
'firstName': 'John',
'lastName': 'Doe'
},
'credentials': {
'local': {
'username': 'admin',
'password': 'myPassword'
}
}
}
);
/*
User {
_id: 'admin',
content:
{ profileIds: ['admin'],
firstName: 'John',
lastName: 'Doe',
_kuzzle_info:
{ author: '-1',
createdAt: 1560351009496,
updatedAt: null,
updater: null } } }
*/
Edit this page on Github(opens new window)