fixed cache bug, enabled logout
This commit is contained in:
parent
5c9e36d569
commit
995d70e3b1
|
@ -363,13 +363,16 @@
|
|||
_get: function (providerUri) {
|
||||
providerUri = OAUTH3.utils.uri.normalize(providerUri);
|
||||
if (!OAUTH3.hooks.directives._cache) { OAUTH3.hooks.directives._cache = {}; }
|
||||
return OAUTH3.PromiseA.resolve(OAUTH3.hooks.directives._cache[providerUri] || this.get(providerUri))
|
||||
return OAUTH3.PromiseA.resolve(OAUTH3.hooks.directives._cache[providerUri]
|
||||
|| OAUTH3.hooks.directives.get(providerUri))
|
||||
.then(function (directives) {
|
||||
// or do .then(this._set) to keep DRY?
|
||||
OAUTH3.hooks.directives._cache[providerUri] = directives;
|
||||
return directives;
|
||||
});
|
||||
}
|
||||
, _getCached: function (providerUri) {
|
||||
providerUri = OAUTH3.utils.uri.normalize(providerUri);
|
||||
return OAUTH3.hooks.directives._cache[providerUri];
|
||||
}
|
||||
, get: function (providerUri) {
|
||||
|
@ -497,14 +500,14 @@
|
|||
throw new Error('oauth3.discover(providerUri, opts) received providerUri as ' + providerUri);
|
||||
}
|
||||
|
||||
return OAUTH3.PromiseA.resolve(OAUTH3.hooks.directives.get(providerUri)).then(function (directives) {
|
||||
return OAUTH3.hooks.directives._get(providerUri).then(function (directives) {
|
||||
if (directives && directives.issuer) {
|
||||
return directives;
|
||||
}
|
||||
return OAUTH3._discoverHelper(providerUri, opts).then(function (directives) {
|
||||
directives.issuer = directives.issuer || OAUTH3.utils.url.normalize(providerUri);
|
||||
// OAUTH3.PromiseA.resolve() is taken care of because this is wrapped
|
||||
return OAUTH3.hooks.directives.set(providerUri, directives);
|
||||
return OAUTH3.hooks.directives._set(providerUri, directives);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -619,21 +622,21 @@
|
|||
});
|
||||
}
|
||||
, logout: function(providerUri, opts) {
|
||||
return OAUTH3._logoutHelper(providerUri, opts);
|
||||
return OAUTH3._logoutHelper(OAUTH3.hooks.directives._getCached(providerUri), opts);
|
||||
}
|
||||
, _logoutHelper: function(providerUri, opts) {
|
||||
var logoutReq = OAUTH3.urls.logout(
|
||||
providerUri
|
||||
, { client_id: (opts.client_id || opts.client_uri || OAUTH3.clientUri(OAUTH3._browser.window.location))
|
||||
, windowType: 'popup' // we'll figure out background later
|
||||
, broker: opts.broker
|
||||
//, state: opts._state
|
||||
, debug: opts.debug
|
||||
}
|
||||
);
|
||||
, _logoutHelper: function(directives, opts) {
|
||||
var logoutReq = OAUTH3.urls.logout(
|
||||
directives
|
||||
, { client_id: (opts.client_id || opts.client_uri || OAUTH3.clientUri(OAUTH3._browser.window.location))
|
||||
, windowType: 'popup' // we'll figure out background later
|
||||
, broker: opts.broker
|
||||
//, state: opts._state
|
||||
, debug: opts.debug
|
||||
}
|
||||
);
|
||||
|
||||
return OAUTH3._browser.frameRequest(
|
||||
OAUTH3.utils.url.resolve(directives.issuer, authReq.url)
|
||||
OAUTH3.utils.url.resolve(directives.issuer, logoutReq.url)
|
||||
, logoutReq.state // state should recycle params
|
||||
, { windowType: 'popup'
|
||||
, reuseWindow: opts.broker && '-broker'
|
||||
|
@ -715,7 +718,7 @@
|
|||
|
||||
// TODO params should have response_type indicating json, binary, etc
|
||||
var directives = JSON.parse(OAUTH3.utils.atob(OAUTH3.utils._urlSafeBase64ToBase64(params.result || params.directives)));
|
||||
// caller will call OAUTH3.hooks.directives.set(providerUri, directives);
|
||||
// caller will call OAUTH3.hooks.directives._set(providerUri, directives);
|
||||
return directives;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue