signUp method

Future<CognitoUserPoolData> signUp(
  1. String username,
  2. String password, {
  3. List<AttributeArg>? userAttributes,
  4. List<AttributeArg>? validationData,
  5. Map<String, String>? clientMetadata,
})

Registers the user in the specified user pool and creates a user name, password, optional user attributes, optional validation data and optional client metadata.

Implementation

Future<CognitoUserPoolData> signUp(
  String username,
  String password, {
  List<AttributeArg>? userAttributes,
  List<AttributeArg>? validationData,
  Map<String, String>? clientMetadata,
}) async {
  final params = {
    'ClientId': _clientId,
    'Username': username,
    'Password': password,
    'UserAttributes': userAttributes,
    'ValidationData': validationData,
    'ClientMetadata': clientMetadata
  };

  if (_clientSecret != null) {
    params['SecretHash'] = CognitoUser.calculateClientSecretHash(
        username, _clientId!, _clientSecret!);
  }

  final data = await client!.request(
      'SignUp', await _analyticsMetadataParamsDecorator.call(params));

  return CognitoUserPoolData.fromData(
    CognitoUser(
      username,
      this,
      storage: storage,
      clientSecret: _clientSecret,
      deviceName: _userAgent,
      analyticsMetadataParamsDecorator: _analyticsMetadataParamsDecorator,
    ),
    data,
  );
}