createArgon2User method

Future<User> createArgon2User({
  1. required String userId,
  2. required String email,
  3. required String password,
  4. String? name,
})

Create a new user. Password provided must be hashed with the Argon2 algorithm. Use the POST /users endpoint to create users with a plain text password.

Implementation

Future<models.User> createArgon2User({
  required String userId,
  required String email,
  required String password,
  String? name,
}) async {
  final String apiPath = '/users/argon2';

  final Map<String, dynamic> apiParams = {
    'userId': userId,
    'email': email,
    'password': password,
    if (name != null) 'name': name,
  };

  final Map<String, String> apiHeaders = {
    'X-Appwrite-Project': client.config['project'] ?? '',
    'content-type': 'application/json',
    'accept': 'application/json',
  };

  final res = await client.call(
    HttpMethod.post,
    path: apiPath,
    params: apiParams,
    headers: apiHeaders,
  );

  return models.User.fromMap(res.data);
}