vue-auth-cognito icon indicating copy to clipboard operation
vue-auth-cognito copied to clipboard

FORCE_CHANGE_PASSWORD state not handled

Open joefresco opened this issue 6 years ago • 1 comments

About a year ago, amazon-cognito-identity-js changed the way that userConfirmationNecessary works.

Here is what vue-auth-cognito has

  return new Promise(function (resolve, reject) {
   return cognitoUser.authenticateUser(authDetails, {
     onFailure: function onFailure(err) {
       reject(err);
     },
     onSuccess: function onSuccess(session, userConfirmationNecessary) {
       commit(types.AUTHENTICATE, constructUser(cognitoUser, session));
       resolve({ userConfirmationNecessary: userConfirmationNecessary });
     }
   });
 });

Note the onSuccess function

Here is amazon-cognito-identity-js use case 23.
Note the newPasswordRequired: function that is used now.

cognitoUser.authenticateUser(authenticationDetails, {
    onSuccess: function (result) {
        // User authentication was successful
    },

    onFailure: function(err) {
        // User authentication was not successful
    },

    mfaRequired: function(codeDeliveryDetails) {
        // MFA is required to complete user authentication.
        // Get the code from user and call
        cognitoUser.sendMFACode(mfaCode, this)
    },

    newPasswordRequired: function(userAttributes, requiredAttributes) {
        // User was signed up by an admin and must provide new
        // password and required attributes, if any, to complete
        // authentication.

        // the api doesn't accept this field back
        delete userAttributes.email_verified;

        // Get these details and call
        cognitoUser.completeNewPasswordChallenge(newPassword, userAttributes, this);
    }
});

Currently, for a user with a current state of FORCE_CHANGE_PASSWORD the error is

Uncaught Error: callback.newPasswordRequired is not a function at eval (CognitoUser.js?88ac:252) at Response.eval (CognitoUser.js?88ac:220) at Request.eval (request.js?1405:364)

joefresco avatar Sep 21 '17 23:09 joefresco

Same issue here, still not handling?

marcoarruda avatar Jul 20 '19 16:07 marcoarruda