SDK
SDK Dart v2.x
2

createUser #

Creates a new user.


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

PropertyTypeDescription
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:

{
  '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 #

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 } } }
  */