Angular AWS Amplify 身份验证器额外字段
Angular AWS Amplify authenticator extrra fields
我正在尝试将 AWS Amplify 与 Angular 一起用于 Cognito 身份验证,我面临的问题是,当我调用组件时:
<amplify-authenticator></amplify-authenticator>
它没有包含我在 Cognito 中标记为必填的所有注册字段,因此它总是 return 错误,例如:缺少字段名称,例如
所以我的问题是,如果他们不 return 我标记为必填的某些字段,我该如何添加它,而不必更改组件本身的源代码。
PS:我正在使用 Angular、aws-amplify-angular。
在撰写此评论时并未显示 Angular 或 React(仅 Vue)的完整版本是可能的,但测试版确实有一些选项。
您可以通过添加以下软件包来获取测试版:
npm install aws-amplify-angular@beta
并将 amplify-authenticator 组件更新为如下所示:
<amplify-authenticator [signUpConfig]="signUpConfig" ></amplify-authenticator>
signupConfig 将在您的组件中设置,看起来像这样:
const signUpConfig = {
header: 'Welcome!',
defaultCountryCode: '46',
hideDefaults: true,
signUpFields: [
{
label: 'Username',
key: 'username',
required: true,
displayOrder: 1,
type: 'string',
},
{
label: 'Password',
key: 'password',
required: true,
displayOrder: 2,
type: 'password',
},
{
label: 'Email',
key: 'email',
required: true,
displayOrder: 3,
type: 'email',
},
{
label: 'Name',
key: 'name',
required: true,
displayOrder: 4,
type: 'string',
},
{
label: 'Family name',
key: 'family_name',
required: true,
displayOrder: 5,
type: 'string',
},
{
label: 'Phone number',
key: 'phone_number',
required: false,
displayOrder: 6,
type: 'string',
}
]
};
详情请见以下两个链接:
https://github.com/aws-amplify/amplify-js/issues/1911#issuecomment-437090097
https://haverchuck.github.io/docs/js/ionic#signup-configuration
我正在尝试将 AWS Amplify 与 Angular 一起用于 Cognito 身份验证,我面临的问题是,当我调用组件时:
<amplify-authenticator></amplify-authenticator>
它没有包含我在 Cognito 中标记为必填的所有注册字段,因此它总是 return 错误,例如:缺少字段名称,例如
所以我的问题是,如果他们不 return 我标记为必填的某些字段,我该如何添加它,而不必更改组件本身的源代码。
PS:我正在使用 Angular、aws-amplify-angular。
在撰写此评论时并未显示 Angular 或 React(仅 Vue)的完整版本是可能的,但测试版确实有一些选项。
您可以通过添加以下软件包来获取测试版:
npm install aws-amplify-angular@beta
并将 amplify-authenticator 组件更新为如下所示:
<amplify-authenticator [signUpConfig]="signUpConfig" ></amplify-authenticator>
signupConfig 将在您的组件中设置,看起来像这样:
const signUpConfig = {
header: 'Welcome!',
defaultCountryCode: '46',
hideDefaults: true,
signUpFields: [
{
label: 'Username',
key: 'username',
required: true,
displayOrder: 1,
type: 'string',
},
{
label: 'Password',
key: 'password',
required: true,
displayOrder: 2,
type: 'password',
},
{
label: 'Email',
key: 'email',
required: true,
displayOrder: 3,
type: 'email',
},
{
label: 'Name',
key: 'name',
required: true,
displayOrder: 4,
type: 'string',
},
{
label: 'Family name',
key: 'family_name',
required: true,
displayOrder: 5,
type: 'string',
},
{
label: 'Phone number',
key: 'phone_number',
required: false,
displayOrder: 6,
type: 'string',
}
]
};
详情请见以下两个链接:
https://github.com/aws-amplify/amplify-js/issues/1911#issuecomment-437090097 https://haverchuck.github.io/docs/js/ionic#signup-configuration