【问题标题】:Aws Cognito- User pools, how to recover / set password for a user when it has no email or phoneAws Cognito - 用户池,当用户没有电子邮件或电话时如何恢复/设置密码
【发布时间】:2017-06-17 10:56:10
【问题描述】:

Aws Cognito- 用户池,当用户没有电子邮件或电话时如何恢复/设置密码。

我在网络上为本地的一家小型企业使用它。 并希望用户仅使用用户名。
不要使用电子邮件和电话。

在验证选项卡上,我将两个复选框:电话和电子邮件留空。

然后它会显示以下红色警告。

You have not selected either email or phone number verification,
so your users will not be able to
recover their passwords without contacting you for support.

所以我希望他们联系支持人员是可以的。 但我找不到 API 来设置他们的密码或由管理员恢复。

如果用户联系我,我该怎么做?

【问题讨论】:

    标签: amazon-web-services authentication amazon-cognito


    【解决方案1】:

    基本上,这意味着您的用户无需验证电子邮件或电话号码。这些可以通过编写验证它们的 lambda 函数来自动验证,或者您可以从控制台代表它们验证它们。

    一旦电话号码或电子邮件被标记为已验证,用户就可以在忘记密码流程中使用它们,他们基本上会得到一个可以用来重置密码的代码。

    您还可以代表他们(从控制台)重置用户密码,这意味着用户将无法登录,并且必须在登录前完成忘记密码流程。同样,电话号码和电子邮件可以标记为从控制台验证。

    【讨论】:

    • 如何获取验证码?因为用户不使用电子邮件或电话。它只有用户名。
    • 如果您的用户没有电子邮件或电话号码,此时管理员无法触发密码更改。他们可以登录并更改密码,但 Cognito 需要向电子邮件地址或电话号码发送验证码以触发管理员密码更改。我会在我们的团队中提及这个请求,以便我们相应地优先考虑它。
    • 如果 cognito 用户池设置为“无验证”,管理员现在可以设置密码吗?
    【解决方案2】:

    目前,通过 API 有一个解决方法。只需设置您/管理员可以接收一次性确认码的电子邮件/电话(例如:support@test.com)

    刚刚在一个旧的 cognito 用户池上进行了测试,由于某种未知原因,它不时将 emailed_verified 属性设置为 false (ref)。

    用户池具有相同的配置:未启用验证选项。

    但是,您可以通过具有开发凭证的 AWS 用户确保 email_verified 属性正常。

    使用 CLI 的示例(在 aws-cli/1.16.3 Python/2.7.10 Darwin/18.2.0 botocore/1.11.3 上测试):

    USER=test@test.com
    POOL_ID=us_east_1-123
    POOL_APP_CLIENT_ID=fake123
    
    # Ensure the email_verified attribute is set to true
    # https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/admin-update-user-attributes.html
    aws cognito-idp admin-update-user-attributes --user-pool-id $POOL_ID --username $USER --user-attributes Name=email_verified,Value=true
    
    # Check the attribute is set/added if missing
    # https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/list-users.html
    aws cognito-idp list-users --user-pool-id $POOL_ID --query 'Users[?Username==`$USER`].[*]'
    
    # Run Admin Reset PWD
    # https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/admin-reset-user-password.html
    aws cognito-idp admin-reset-user-password --user-pool-id <Pool ID> --username <USER>
    # The email/phone for the user should get a confirmation code
    # Set the new pwd
    # https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/confirm-forgot-password.html
    aws cognito-idp confirm-forgot-password --confirmation-code <Code> --password <New PWD> --username $USER --client-id $POOL_APP_CLIENT_ID
    

    【讨论】:

      猜你喜欢
      • 2018-01-24
      • 1970-01-01
      • 2020-08-25
      • 2019-07-30
      • 2018-01-21
      • 2011-10-07
      • 2018-05-01
      • 2020-12-08
      • 2019-08-01
      相关资源
      最近更新 更多