Commit e15f5740 authored by Sean Hammond's avatar Sean Hammond

Simplify tokenGetter()

parent dbcb5881
...@@ -36,25 +36,23 @@ function auth($http, settings) { ...@@ -36,25 +36,23 @@ function auth($http, settings) {
} }
function tokenGetter() { function tokenGetter() {
if (accessTokenPromise) { if (!accessTokenPromise) {
return accessTokenPromise;
} else {
var grantToken; var grantToken;
if (Array.isArray(settings.services) && settings.services.length > 0) { if (Array.isArray(settings.services) && settings.services.length > 0) {
grantToken = settings.services[0].grantToken; grantToken = settings.services[0].grantToken;
} }
if (!grantToken) { if (grantToken) {
return Promise.resolve(null); accessTokenPromise = exchangeToken(grantToken).then(function (tokenInfo) {
return tokenInfo.access_token;
});
} else {
accessTokenPromise = Promise.resolve(null);
} }
accessTokenPromise = exchangeToken(grantToken).then(function (tokenInfo) {
return tokenInfo.access_token;
});
return accessTokenPromise;
} }
return accessTokenPromise;
} }
// clearCache() isn't implemented (or needed) yet for OAuth. // clearCache() isn't implemented (or needed) yet for OAuth.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment