Closed rakeshtembhurne closed 7 years ago
It doesn't look like this PR adds any value to the project. Closing unless proven otherwise.
Hi Vladimir,
Issue and its replication I was trying to update name of the current logged in user, for which I created a function in class CognitoUtil
.
updateCredentials(): void {
var attributeList = [];
var attribute = {
Name : 'nickname',
Value : 'Rakesh'
};
attribute = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(attribute);
attributeList.push(attribute);
var cognitoUser = this.getCurrentUser();
cognitoUser.updateAttributes(attributeList, function(err, result) {
if (err) {
console.warn(err);
return;
}
console.info('call result: ' + result);
});
}
This function fails with following error:
Trying to figure out the issue, I found that this line might be causing this issue:
return new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(CognitoUtil._POOL_DATA);
This line is present in CognitoUtil::getUserPool()
and called when try to get current user (CognitoUtil::getCurrentUser()
function)
Gist file in my previous message contains solution I created, and worked for me. So in short the issue is calling getCurrentUser()
function sends back unauthenticated user.
Issue:
CognitoUtil::getCurrentUser();
returns wrong or unauthenticated version of current user.Issue Replication https://gist.github.com/rakeshtembhurne/5e2f02abe78588fad0f66bb3e6881d43
Above is the diff shows code working correctly. Replacing old
getUserPool()
andgetCurrentUser()
causes errors.