代码之家  ›  专栏  ›  技术社区  ›  Johan Rin

AWS Amplify身份验证模块禁用的用户池属性

  •  2
  • Johan Rin  · 技术社区  · 7 年前

    我在angular项目中使用CLI工具链配置了放大身份验证模块。

    documentation documentation

    不幸的是,我在控制台中看到所有字段都被禁用。

    禁用它是因为我错过了自动设置中的某些内容,还是因为现在无法使用CLI并且我需要提供手动设置?

    3 回复  |  直到 7 年前
        1
  •  9
  •   Johan Rin    7 年前

    编辑2019-04-11:

    不再需要手动更新配置文件。

    AWS CLI


    原始答案

    existing issue 关于本主题,介绍一种调整用户池属性的方法。

    amplify/backend/auth/<project_name>/<project_name>-cloudformation-template.yml

    就在台词后面:

    Type: AWS::Cognito::UserPool
    Properties:
      UserPoolName: !Ref userPoolName
    

    添加行:

      UsernameAttributes:
        - 'email'
    

    并用 amplify push

        2
  •  7
  •   weibeld    7 年前

    here

    而且在CLI中似乎没有办法配置用户池,以便选中“Email address or phone number”单选按钮而不是“Username”按钮。

    因此,如果要在运行放大CLI后将电子邮件用作“用户名”,则有两个选项:

    方案1

    保留所有用户池设置,并调用 signUp 方法如下:

        signup(email, password, email)
    

    方案2

    1. 在AWS控制台中手动创建一个新的用户池,并在创建时将属性单选按钮设置为“Email address or phone number”。

      enter image description here

    2. 在你的 main.ts 文件,覆盖 userPoolId userPoolWebClientId 配置来自 aws-exports.js

      import Amplify from 'aws-amplify';
      import amplify from './aws-exports';
      
      Amplify.configure(amplify);
      Amplify.configure({
        Auth: {
          userPoolId: 'us-east-1_jZIcja1eI',
          userPoolWebClientId: '80e40l0hvvrct4avi3buceekf',
        }
      });
      

      您可以在此处找到值:

      • enter image description here

      • 对于 ,创建新的应用程序客户端并复制其ID:

        enter image description here

        创建应用程序客户端时,请确保取消选择“生成客户端密码”,否则将出现错误 Unable to verify secret hash for client 调用 注册 方法:

        enter image description here

        对于应用程序客户端的名称,您可以选择任何您想要的内容。

    差异

    选项2(使用电子邮件地址登录)

    以下 错误 尝试使用已存在的用户名(选项1)或电子邮件地址(选项2)注册新用户时返回:

    enter image description here

    enter image description here

        3
  •  0
  •   Pedro Silva    7 年前

    创建用户池后,无法更改某些参数(删除属性、更改sms身份验证)。因此,不幸的是,解决方案是小心地创建一个新的用户池。Aws有这个问题,也许将来他们会解决。

    推荐文章