我正在尝试为我的应用程序创建登录页面。它是纯html、css和JS。我已经在AWS-cognito cl中创建了用户,但当我尝试使用凭据时,它无法登录,我得到的唯一信息是这是一个未知错误。
我试着在这个问题上找到一些东西,但什么也没有出现。我找到的许多答案都涉及到newPasswordRequired函数或正在使用的sdk的版本。我已经反复检查了我的用户池id和客户端id。
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,我只想用一个用户登录并通过管理员设置的MFA,这可能是我在cl中设置的错误。
发布于 2019-10-14 05:24:30
在这里做的明智的事情是看一下我是如何处理newPassword函数的。我没有给它一种方式或机会来更改密码,因为我的应用程序要求用户登录,这是管理员创建的,这要求用户在登录时更改密码。
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);
}https://stackoverflow.com/questions/58331740
复制相似问题