AWS Cognito completeNewPasswordChallenge calls onFailure method but the user is confirmed in AWS Console

血红的双手。 提交于 2019-12-05 14:18:24
Jonathan

I believe you need to call completeNewPasswordChallenge within the newPasswordRequired callback.

newPasswordRequired: (userAttributes, requiredAttributes) => {
          delete userAttributes.email_verified

          cognitoUser.completeNewPasswordChallenge(newPw, userAttributes, {
            onSuccess: result => {
              AWS.config.credentials.refresh(err => {
                if (err) {
                  throw err
                } else {
                  // do something
                }
              })
            },
            newPasswordRequired: (userAttributes, requiredAttributes) => {
              delete userAttributes.email_verified
              // phone number as well

              cognitoUser.completeNewPasswordChallenge(newPw, userAttributes, this.newPasswordRequired)
            },
            onFailure: err => {
              throw err
            }
          })
        },
NN88

I believe you have MFA on your account and you need to handle it from callback:

mfaSetup: (challengeName, challengeParameters) => { ... }

When you're handling mfaSetup form cognitoUser.authenticateUser() callback all is good if it's required, but from completeNewPasswordChallenge() callback there is no mfaSetup() in typings, which I believe AWS colleagues should fix it ASAP.

That's why you have empty error code, please check response tab in network dev tools on post req you made. I believe you'll find there MFA_SETUP challenge to solve.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!