From c10c131f085743358609485ff3de5d908348bc99 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Wed, 30 Aug 2017 16:01:34 +0300 Subject: [PATCH] Don't set credentials if they aren't first refreshed --- aws-cognito.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aws-cognito.html b/aws-cognito.html index 07a4a19..408df1b 100644 --- a/aws-cognito.html +++ b/aws-cognito.html @@ -550,7 +550,9 @@ const params = {IdentityPoolId, Logins}; const credentials = new AWS.CognitoIdentityCredentials(params); credentials.expired = true; - this._setCredentials(credentials); + credentials.refresh((error) => + error ? this.fireError(error) + : this._setCredentials(AWS.config.credentials)); this.refreshCredentials(); }, @@ -611,8 +613,9 @@ let credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId}); credentials.clearCachedId(); // https://github.com/aws/aws-sdk-js/issues/609 credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId}); - this._setCredentials(credentials); - this.refreshCredentials(); + credentials.refresh((error) => + error ? this.fireError(error) + : this._setCredentials(AWS.config.credentials)); }, /**