amazon-cognito-identity-js icon indicating copy to clipboard operation
amazon-cognito-identity-js copied to clipboard

Verification code timeout

Open ghost opened this issue 7 years ago • 3 comments

I have a very strange bug :

If users directly try to confirm them account with the verification code received by email they always have this error message : "ExpiredCodeException: Invalid code provided, please request a code again" eventhough them account is well confirmed in the user pool...

But If they register themselves and they wait few minutes to try to confirm them account its works perfectly !

This is how I confirm the verification code :

confirmRegistration: function(verificationCode, username, _poolData) {
    var deferred = $q.defer();
    var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(_poolData);
    var userData = {
            Username : username,
            Pool : userPool
        };
    cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
    cognitoUser.confirmRegistration(verificationCode, true, function(err, result) {
            if (err) {
                    alert(err);
                    deferred.reject('confirmation failled.');
            }
            deferred.resolve('successfully confirmed.')
    });
    return deferred.promise;
},

How could I fixe it ? Where is from this problem ? Do there is a timeout to set somewhere ?

ghost avatar May 10 '17 08:05 ghost

Confirmation and verification code are valid for 24 hours and this is not configurable at the moment ...

itrestian avatar May 11 '17 21:05 itrestian

Thanks for your answer @itrestian but that not my problem. The problem is than I have a message eror if I try to validate a verification code just after receive it. To don't have an error message I have to wait almost 1 minute after received the verification code to validate it... Why ?

ghost avatar May 12 '17 07:05 ghost

Same issue here except I'm using node-js sdk.

warrenronsiek avatar Jun 29 '17 18:06 warrenronsiek