Commit e15f5740 authored by Sean Hammond's avatar Sean Hammond

Simplify tokenGetter()

parent dbcb5881
...@@ -36,26 +36,24 @@ function auth($http, settings) { ...@@ -36,26 +36,24 @@ 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) { accessTokenPromise = exchangeToken(grantToken).then(function (tokenInfo) {
return tokenInfo.access_token; return tokenInfo.access_token;
}); });
} else {
accessTokenPromise = Promise.resolve(null);
}
}
return accessTokenPromise; return accessTokenPromise;
} }
}
// clearCache() isn't implemented (or needed) yet for OAuth. // clearCache() isn't implemented (or needed) yet for OAuth.
// In the future, for example when OAuth-authenticated users can login and // In the future, for example when OAuth-authenticated users can login and
......
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