【发布时间】:2021-12-19 12:37:27
【问题描述】:
我正在使用 Flutter 开发移动应用程序。 我不知道如何解决这个问题。 我正在使用 AWS Cognito 进行用户验证
这是我的代码
void _signUp() {
final username = _usernameController.text.trim();
final password = _passwordController.text.trim();
final passwordConfirm = _passwordConfirmController.text.trim();
final email = _emailController.text.trim();
final gender = _isGenderSelected[0] == true ? 'male' : 'female';
final birthMonth = _birthMonthController!.length <= 1 ? '0' + _birthMonthController! : _birthMonthController!;
final birthDay = _birthDayController!.length <= 1 ? '0' + _birthDayController! : _birthDayController!;
final birthdate = '$birthMonth/$birthDay/$_birthYearController';
print('username: $username');
print('password: $password');
print('password confirm: $passwordConfirm');
print('email: $email');
print('gender: $gender');
print('birthdate: $birthdate');
if (password == passwordConfirm) {
final credentials = SignUpCredentials(
username: username,
password: password,
email: email,
gender: gender,
birthdate: birthdate
);
widget.didProvideCredentials(credentials);
}
else
print('Password does not match');
}
这是我在运行控制台中遇到的错误
I/flutter (13290): username: gs97ahn
I/flutter (13290): password: 1234567890
I/flutter (13290): password confirm: 1234567890
I/flutter (13290): email: gs97ahn@naver.com
I/flutter (13290): gender: male
I/flutter (13290): birthdate: 02/11/1997
E/UserContextDataProvider(13290): Exception in creating JSON from context data
E/amplify:flutter:auth_cognito(13290): InvalidParameterException
E/amplify:flutter:auth_cognito(13290): InvalidParameterException{message=One or more parameters are incorrect., cause=com.amazonaws.services.cognitoidentityprovider.model.InvalidParameterException: 1 validation error detected: Value 'custom:birthdate:' at 'attributes.3.member.name' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[\p{L}\p{M}\p{N}_.-]+(:[\p{L}\p{M}\p{N}_.-]+)*$ (Service: AmazonCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: a41e4c3c-09eb-401a-9891-f957ce0004c3), recoverySuggestion=Enter correct parameters.}
【问题讨论】:
标签: amazon-web-services flutter amazon-cognito