AWS Cognito -- 默认情况下需要提供电子邮件,但默认注册表单没有电子邮件字段

问题描述 投票:0回答:1

我正在关注本教程,但我陷入了使用 aws cognito 添加身份验证的阶段。我运行了

amplify add auth
并接受了所有默认值。然后我就跑了
amplify push --y

现在,当我运行应用程序时,我的注册屏幕只有 3 个字段:用户名、密码和确认密码。没有地方可以输入电子邮件。但是,当我单击“创建帐户”时,出现错误

Attributes did not conform to the schema: email: The attribute is required

如何设置电子邮件字段,或以其他方式解决此问题?

reactjs amazon-web-services amazon-cognito aws-amplify
1个回答
0
投票

如果您仍然遇到此问题,那么您可以直接尝试使用

Authenticator
组件,而不是像此处所示的
withAuthenticator
步骤 3. 添加身份验证器

另外,我刚刚在signupAttributes属性中添加了

email
。请参阅this了解更多详情。

export default function App() {
  return (
    <Authenticator signUpAttributes={['email']}>
      {({ signOut, user }) => (
        <main>
          <h1>Hello {user.username}</h1>
          <button onClick={signOut}>Sign out</button>
        </main>
      )}
    </Authenticator>
  );
}
© www.soinside.com 2019 - 2024. All rights reserved.