簡體   English   中英

amazon-cognito-identity-js - 忘記了無效用戶的密碼

[英]amazon-cognito-identity-js - forgot password for Invalid User

我正在使用 amazon-cognito-identity-js 節點模塊來實現忘記密碼。 下面是我的服務代碼。

 var userData = {
    Username: '<username>',
    Pool: '<userpool id>',
  }

var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData)
  return new Promise(function (resolve, reject) {
    cognitoUser.forgotPassword({
      onSuccess: function (data) {
        resolve({
          statusCode: 200, response: {
            ForgotPasswordResponse: {
              Status: 'Success',
              Destination: data.CodeDeliveryDetails.Destination
            },
          }
        })
      },
      onFailure: function (err) {
        resolve({
          statusCode: 400, response: {
            ForgotPasswordResponse: {
              Status: 'failure',
              Error: err.message
            },
          }
        })
      }
    });
  })
}

如果我傳遞不在池中的用戶名,代碼仍然會進入 onSuccess function 並且不知道它向哪個目的地發送驗證碼。 如果我傳遞在 Cognito 用戶池中狀態為 FORCE_CHANGE_PASSWORD 的用戶名,也會發生同樣的事情。 請建議處理這種情況。

在使用 amazon-cognito-identity-js 將 Congito 集成到網站中進行身份驗證時,如果在 Cognito 池中標記了某些設置,則忘記密碼方法將無法正常工作。

原Congtio界面導航到設置Cognito User Pool -> General Settings -> App Clients -> Show Details -> Security Configuration -> Prevent User Existence Errors

如果您 select “已啟用(推薦)”,那么在提交用戶池中不存在的用戶時,忘記密碼 API 將永遠不會返回失敗。

如果將其切換回“舊版”,則忘記密碼 API 將再次正常工作。

我已將此問題通知 AWS,希望他們會考慮修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM