I've added an authorization to my angular app using amplify add auth
.
After that I've added
"requiredAttributes": [
"email",
"custom:firstName",
"custom:lastName"
],
to the amplify/backend/auth/XXX/parameters.json
and
Schema:
-
Name: email
Required: true
Mutable: true
-
AttributeDataType: "String"
Mutable: true
Name: firstName
StringAttributeConstraints:
MaxLength: 256
MinLength: 1
-
AttributeDataType: "String"
Mutable: true
Name: lastName
StringAttributeConstraints:
MaxLength: 256
MinLength: 1
to the amplify/backend/auth/XXX/XXX-cloudformation-template.yml
After that amplify push
.
I can see these custom filds in Console:
but when I try to send custom fields like this:
import { Auth } from 'aws-amplify';
...
signUp(email, password, firstName, lastName): Observable<any> {
return fromPromise(Auth.signUp(
email,
password,
attributes: {
"custom:firstName": firstName,
"custom:lastName": lastName
}
));
}
TypeScript compiler thrown this error:
Cannot find name 'attributes'.ts
It should be:
signUp(params: string | SignUpParams, ...restOfAttrs: string[]): Promise<ISignUpResult>
This is my workaround:
signUp(username, password, firstName, lastName): Observable<any> {
const signUpParams: any = {
username,
password,
attributes: {
'custom:firstName': firstName,
'custom:lastName': lastName
}
};
return fromPromise(Auth.signUp(
signUpParams
));
}