Dart 2.x

createUser

Creates a new user.


Copied to clipboard!
Future<KuzzleUser> createUser(String id, 
      Map<String, dynamic> body,
      {bool waitForRefresh})

Property Type Description
id
String
User id
body
Map<String, dynamic>
User content & credentials
waitForRefresh
boolean

(null)
If set to true, Kuzzle will not respond until the created user is indexed

If the kuid is null, Kuzzle will generate an ID.

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 the profileIds 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:

Copied to clipboard!
{
  'content': {
    'profileIds': [
      'default'
    ],
    'firstName': 'John',
    'lastName': 'Doe'
  },
  'credentials': {
    'local': {
      'username': 'admin',
      'password': 'myPassword'
    }
  }
}

Resolves

A User object containing information about the newly created user.

Usage

Copied to clipboard!
final result = await kuzzle.security.createUser('jdoe', {
  'content': {
    'profileIds': [ 'default' ]
  },
  'credentials': {
    'local': {
      'username': 'jdoe',
      'password': 'password'
    }
  }
});
/*
User {
  _id: 'john.doe',
  content:,
    { profileIds: [ 'default' ],
      firstName: 'John',
      lastName: 'Doe',
      fullName: 'John Doe',
      _kuzzle_info:
        { author: '-1',
          createdAt: 1561379086534,
          updatedAt: null,
          updater: null } } }
  */