I am having an odd problem when trying to authenticate my users. Below is my code.
//-----Authenticate a user
alert('Authenticate a user with application');
var authenticationData = {
Username : 'someExistingUserName',
Password : 'passwordForExistingUserName',
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var poolData = { UserPoolId : 'us-east-1_r121212',
ClientId : '3g7djfhsdfjkahfjdfhdb1'
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var userData = {
Username : 'someExistingUserName',
Pool : userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
alert('hisss2');
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
alert('meow');
console.log('access token + ' + result.getAccessToken().getJwtToken());
},
onFailure: function(err) {
alert(err);
},
});
It seems to be working in a sense.
If I put in a non existent username/password combination I get the following seemingly correct error:
ResourceNotFoundException: Username/client id combination not found.
If, however, I put in a correct user name and password combination, nothing seems to happen. No error pop up occurs(which was happening when i had a wrong username/password combo), and the console.log that is meant to run onSuccess of authentication does not, nor does any alert pop up I place inside the onSuccess handler.
It is neither triggering onSuccess or onFailure, which just seems weird. Really weird. Thoughts? I'm pretty sure my set up is correct in terms of using the correct UserPoolId, ClientId etc. This seems quite odd. Please help, I can offer you nothing in return.
I had an additional thought, is the Username parameter here:
var authenticationData = {
Username : 'someExistingUserName',
Password : 'passwordForExistingUserName',
};
Meant to be matching the Username parameter here:
var userData = {
Username : 'someExistingUserName',
Pool : userPool
};
? Mine currently do, but perhaps they are two different usernames and I'm only using one or something? WTF.