【问题标题】:aws-amplify forgot password function with react js sending SMS instead of emailaws-amplify忘记密码功能,反应js发送短信而不是电子邮件
【发布时间】:2019-06-18 04:48:43
【问题描述】:

我使用 aws-amplify 构建了一个允许 Cognito 用户登录的应用程序。但是,Auth.forgotPassword 似乎将 SMS 发送到移动设备而不是 EMAIL。如何更改发送电子邮件的行为?

相关代码如下:

Auth.forgotPassword(this.state.username)
  .then(data => this.setState({instruction: 'An email has been sent to your email with a temporary password.', usernameError: false, passwordError: false}))
  .catch(err => this.setState({instruction: err.message, usernameError: false, passwordError: false}));

【问题讨论】:

    标签: reactjs amazon-web-services aws-amplify


    【解决方案1】:

    您可以配置在 AWS Cognito 控制台中触发忘记密码 API 时需要验证的内容。

    Amazon Cognito > 管理用户池 > 选择您的池 > 常规设置 > MFA 和验证 > Which attributes do you want to verify?

    此外,当您触发 ForgotPassword API 时,您会得到 CodeDeliveryDetails 对象作为响应

    const result = await Auth.forgotPassword(username);
    

    console.log(结果);

    CodeDeliveryDetails: {
        "AttributeName": "email",
        "DeliveryMedium": "EMAIL",
        "Destination": "n***@g***.com"
      }
    

    从结果中,您可以了解代码是在哪个介质上交付的,并相应地在应用程序中通知用户。

    【讨论】:

      猜你喜欢
      • 2020-03-26
      • 2016-08-31
      • 2011-02-19
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 2015-06-22
      • 2013-06-13
      • 2013-03-04
      相关资源
      最近更新 更多