Skip to content

Commit

Permalink
Fix for credentials promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Benny Powers committed Jul 11, 2017
1 parent 753517b commit 447a442
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions aws-cognito.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,14 @@

/**
* Refreshes the user's credentials
* @return {Promise} promise resolves to user's credentials
*/
refreshCredentials: function() {
this._log.info('Trying to refresh credentials');
const userPool = this._getCognitoUserPool();
const cognitoUser = userPool.getCurrentUser();
this._getCognitoSession(cognitoUser).then((cognitoSession) => {
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
this._getCognitoSession(cognitoUser).then((cognitoSession) => {
if (!cognitoUser) {
let msg = 'No Cognito user found while trying to refresh credentials';
this._log.warn(msg);
Expand All @@ -333,8 +334,10 @@
reject(msg);
} else {
this._refreshCognitoCredentials(cognitoUser, cognitoSession)
.then((credentials) =>
this._dispatchCredentials(credentials, cognitoUser, cognitoSession))
.then((credentials) => {
resolve(credentials);
this._dispatchCredentials(credentials, cognitoUser, cognitoSession);
})
.catch((error) => this._handleError(error));
}
});
Expand Down

0 comments on commit 447a442

Please sign in to comment.