AWS Cognito пароль сбрасывается не работает - PullRequest
0 голосов
/ 15 мая 2018

Я новичок в службе AWS Cognito. Это мой фрагмент кода. Он не работает для сброса пароля.

Пожалуйста, проверьте следующий код и верните меня для изменения в коде.

        var EmailId = document.getElementById('email').value;
        //var Password = document.getElementById('txtPassword').value
        $.ajax({
            url: EndPointURL + '/userapproval',
            type: 'GET',
            data: JSON.stringify(EmailId),
            contentType: 'application/json; charset=utf-8',
            async: false,
            success: function (response) {
                var data = JSON.parse(response);
                //alert(data);
                var len = data.length;
                //alert('len : ' + len);
                for (var i = 0; i < len; i++) {
                    if (EmailId === data[i].EmailId) {
                        var status = data[i].status;

                        if (status.toLowerCase() !== "rejected") {
                            // When using loose Javascript files:
                            var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;

                            var authenticationData = {
                                Username: EmailId
                                //Password: Password,
                            };
                            var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
                            var poolData = {
                                UserPoolId: poolId, // Your user pool id here
                                ClientId: clientId // Your client id here
                            };
                            var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
                            var userData = {
                                Username: EmailId,
                                Pool: userPool
                            };

этот код для сброса пароля не работает, я пытаюсь большинство изменений в коде, но не ответ: -

                            var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);

                            cognitoUser.forgotPassword({                                    
                                onSuccess: function (result) {
                                    // console.log('call result: ' + result);
                                },
                                onFailure: function (err) {
                                    //alert(err);
                                    $("#lbl_alert").html(err);
                                    $("#myAlertModal").modal('show');
                                },
                                //Optional automatic callback
                                inputVerificationCode: function (data) {
                                    //console.log('Code sent to: ' + data);
                                    var verificationCode = prompt('Please input verification code ', '');
                                    if (verificationCode == null) {
                                        return false; //break out of the function early
                                    }
                                    if (verificationCode === '')
                                        return false;
                                    var newPassword = prompt('Enter new password ', '');
                                    if (newPassword == null) {
                                        return false; //break out of the function early
                                    }
                                    cognitoUser.confirmPassword(verificationCode, newPassword, this);                                       
                                    //alert("Password reset successfully.");
                                    $("#lbl_alert").html("Password reset successfully.");
                                    $("#myAlertModal").modal('show');
                                    document.location = 'Login.html';
                                }
                            });
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...