SDK
SDK Dart v1.x
2

# 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).


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

Property Type Description
body
Map<String, dynamic>
User content & credentials
kuid
String
User kuid. If not provided, a random kuid is automatically generated
waitForRefresh
boolean

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

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

Copied to clipboard!
{
  'content': {
    'firstName': 'John',
    'lastName': 'Doe'
  },
  'credentials': {
    'local': {
      'username': 'jdoe',
      'password': 'password'
    }
  }
}

# Resolves

A User object containing information about the newly created user.

# Usage

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