我已經創建了一個AWS認證用戶池,其中包含必需的電子郵件屬性並檢查了電子郵件以進行驗證。用戶使用AWSCognitoClient sdk並調用adminCreateUser(createUser)方法從我的java spring後端服務創建。用戶會收到一封帶有臨時密碼的電子郵件,該密碼將在第一次登錄時設置新密碼。現在,當我執行忘記密碼流,我收到以下錯誤,AWS認證忘記密碼流
InvalidParameterException: Cannot reset password for the user as there is no registered/verified email or phone_number
雖然我收到一個臨時密碼的電子郵件ID我註冊了,並改變了我的密碼,我第一次出現上述錯誤。有人能解釋我錯過了什麼嗎?
下面是JavaScript代碼執行我爲忘記密碼流,
forgotPassword(username: String, poolInfo:any){
var poolData = {
UserPoolId : poolInfo.poolId, // Your user pool id here
ClientId : poolInfo.portalClientId // Your client id here
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var userData = {
Username : username,
Pool : userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.forgotPassword({
onSuccess: function (result) {
this.router.navigate(['login']);
},
onFailure: function(err) {
alert(err);
},
//Optional automatic callback
inputVerificationCode: function(data) {
var verificationCode = prompt('Please input verification code ' ,'');
var newPassword = prompt('Enter new password ' ,'');
cognitoUser.confirmPassword(verificationCode, newPassword, this);
}
});
}
請標明答案 – Efren