Javascript 为什么在AWS cognito CL中尝试使用用户设置登录时出现未知错误?
我正在尝试为我的应用程序创建登录页面。它是纯html css和JS。我已经在AWS cognito cl中创建了用户,但当我尝试使用凭据时,它无法登录,我得到的唯一信息是,这是一个未知错误 我试图找到一些关于这方面的东西,但什么都没有发生。我找到的很多答案都涉及newPasswordRequired函数或正在使用的sdk版本。我已经仔细检查了我的用户池id和客户端idJavascript 为什么在AWS cognito CL中尝试使用用户设置登录时出现未知错误?,javascript,authentication,browser,admin,amazon-cognito,Javascript,Authentication,Browser,Admin,Amazon Cognito,我正在尝试为我的应用程序创建登录页面。它是纯html css和JS。我已经在AWS cognito cl中创建了用户,但当我尝试使用凭据时,它无法登录,我得到的唯一信息是,这是一个未知错误 我试图找到一些关于这方面的东西,但什么都没有发生。我找到的很多答案都涉及newPasswordRequired函数或正在使用的sdk版本。我已经仔细检查了我的用户池id和客户端id function signInButton() { var authenticationData = {
function signInButton() {
var authenticationData = {
Username : document.getElementById("inputUsername").value,
Password : document.getElementById("inputPassword").value,
};
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId : _config.cognito.userPoolId,
ClientId : _config.cognito.clientId,
};
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var userData = {
Username : document.getElementById("inputUsername").value,
Pool : userPool,
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
resolve(result.getAccessToken().getJwtToken());
},
onFailure: function (err) {
console.log("Error from cognito promise: ", err);
},
newPasswordRequired: function (userAttributes) {
delete userAttributes.email_verified;
cognitoUser.completeNewPasswordChallenge(newPassword, userAttributes, this);
}
});
};
我想让它做的显然是登录并转到指定的页面,我知道错误函数确实起作用,因为在此之前,我实际上得到了信息。我不想也不需要MFA,我只是想用管理员设置的用户登录并通过,可能是我在cl中设置了错误。这里要做的明智之举是看看我是如何处理新密码功能的。我没有给它一个改变密码的方式或机会,因为我的应用程序要求用户登录,这是管理员创建的,需要用户在登录时改变密码
newPasswordRequired: function (userAttributes,requiredAttributes) {
delete userAttributes.email_verified;
let attributesData = {name: authenticationData.Username}
var newPassword = prompt('Enter new password ' ,'');
cognitoUser.confirmPassword( newPassword, this);
cognitoUser.completeNewPasswordChallenge(newPassword, attributesData, this);
}