【问题标题】:AWS Cognito Forgot PasswordAWS Cognito 忘记密码
【发布时间】:2022-08-13 03:10:30
【问题描述】:
import { Auth } from \'aws-amplify\';

// Send confirmation code to user\'s email or phone
Auth.forgotPassword(username)
    .then(data => console.log(data))
    .catch(err => console.log(err));

// Collect confirmation code and new password, then
Auth.forgotPasswordSubmit(username, code, new_password)
    .then(data => console.log(data))
    .catch(err => console.log(err));

我想在用户的电话号码或电子邮件未验证时捕捉到,因此我可以重新发送验证码或让用户知道。

我想我在文档中的某处看到如果电话/电子邮件未经过验证,放大应该引发错误,但事实并非如此。它将返回它已将代码发送到用户提供的电话/电子邮件,但他们永远不会收到此代码(我假设它未经过验证)。

他们实际上从未收到来自.forgotPassword 的代码,而从我这边(或在代码中),data 的响应看起来就像是代码已发送。但是.forgotPasswordSubmit 没有代码就无法工作。

如果用户的电话/电子邮件没有经过验证,我如何捕捉到他们是否真的收到了代码?

    标签: reactjs amazon-web-services promise amazon-cognito


    【解决方案1】:

    不幸的是,这是不可能的。 有关详细信息,请参阅文档: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ForgotPassword.html

    尽管当您调用 ForgotPassword 端点时,API 应该为我们提供有关某些用户名的未验证电子邮件的例外情况,但我没有收到任何信息。

    如果既不存在已验证的电话号码也不存在已验证的电子邮件,则会引发 InvalidParameterException。

    所以它仍然像一个结果不确定的黑匣子。

    作为开发人员,您唯一能做的就是给您的用户一个显着的提示,以在他们第一次登录时验证他们的邮件地址。

    【讨论】:

      猜你喜欢
      • 2018-02-22
      • 1970-01-01
      • 1970-01-01
      • 2018-04-12
      • 2017-10-09
      • 2012-07-25
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      相关资源
      最近更新 更多