【发布时间】:2019-08-27 12:05:30
【问题描述】:
您好,我正在尝试使用内置的 Angular 组件进行身份验证。 我用 Amplify 创建了 Cognito 和 API。 Cognito 用户池无法更改。 这是一个屏幕截图,您也可以在其中看到设置:
我已经像这样初始化组件:
<ion-content padding>
<amplify-authenticator [signUpConfig]="signUpConfig" framework="ionic"></amplify-authenticator>
</ion-content>
我的课程包含这个用于 signUpConfig:
constructor(
public events: Events,
public amplifyService: AmplifyService,
public router: Router
) {
this.authState = { signedIn: false };
this.signUpConfig = {
header: "SignUp",
defaultCountryCode: '30',
hideAllDefaults: true,
signUpFields: [
{
label: 'Mobile-Username',
key: 'username',
required: true,
displayOrder: 1,
type: 'string'
},
{
label: 'Mobile',
key: 'phone_number',
required: true,
displayOrder: 2,
type: 'string'
},
{
label: 'Password',
key: 'password',
required: true,
displayOrder: 3,
type: 'password'
},
{
label: 'Email',
key: 'email',
required: true,
displayOrder: 4,
type: 'email'
},
{
label: 'Name',
key: 'name',
required: true,
displayOrder: 5,
type: 'string'
},
{
label: 'Surname',
key: 'family_name',
required: true,
displayOrder: 6,
type: 'string'
},
{
label: 'Address',
key: 'address',
required: true,
displayOrder: 7
},
{
label: 'Gender',
key: 'gender',
required: true,
displayOrder: 8
}
]
};
}
不幸的是,我必须包括
{
label: 'Mobile-Username',
key: 'username',
required: true,
displayOrder: 1,
type: 'string'
},
为了使用手机号码填充用户名,因为 Cognito UserPool 正在等待 username 和 mobile number,尽管从设置中可以清楚地看到我只需要手机作为我的用户名。
如果我离开我的signUpFields 的第一个条目,那么我总是会从服务器收到username cannot be empty 的错误。
我应该做什么,尤其是现在我无法对我的用户池进行任何更改。我相信这是因为我使用 Amplify CLI 来设置它。
【问题讨论】:
标签: angular ionic-framework amazon-cognito aws-amplify