From 356a2d3131bcc6d0f6199a1d2039dcdcee0e3481 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 2 Mar 2017 13:08:14 -0700 Subject: [PATCH] fix _getCached --- oauth3.core.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oauth3.core.js b/oauth3.core.js index 0756e77..dd3fea9 100644 --- a/oauth3.core.js +++ b/oauth3.core.js @@ -397,8 +397,7 @@ directives: { get: function (providerUri) { providerUri = OAUTH3.uri.normalize(providerUri); - if (!OAUTH3.hooks.directives._cache) { OAUTH3.hooks.directives._cache = {}; } - return OAUTH3.PromiseA.resolve(OAUTH3.hooks.directives._cache[providerUri] + return OAUTH3.PromiseA.resolve(OAUTH3.hooks.directives._getCached(providerUri) || OAUTH3.hooks.directives._get(providerUri)) .then(function (directives) { // or do .then(this._set) to keep DRY? @@ -408,6 +407,7 @@ } , _getCached: function (providerUri) { providerUri = OAUTH3.uri.normalize(providerUri); + if (!OAUTH3.hooks.directives._cache) { OAUTH3.hooks.directives._cache = {}; } return OAUTH3.hooks.directives._cache[providerUri]; } , set: function (providerUri, directives) { @@ -511,6 +511,7 @@ } , _getCached: function (providerUri) { providerUri = OAUTH3.uri.normalize(providerUri); + if (!OAUTH3.hooks.session._cache) { OAUTH3.hooks.session._cache = {}; } return OAUTH3.hooks.session._cache[providerUri]; } , set: function (providerUri, newSession) { @@ -528,9 +529,8 @@ if (!providerUri) { throw new Error("providerUri is not set"); } - if (!OAUTH3.hooks.session._cache) { OAUTH3.hooks.session._cache = {}; } - return OAUTH3.PromiseA.resolve(OAUTH3.hooks.session._cache[providerUri] + return OAUTH3.PromiseA.resolve(OAUTH3.hooks.session._getCached(providerUri) || OAUTH3.hooks.session._get(providerUri)).then(function (session) { OAUTH3.hooks.session._cache[providerUri] = session; return session;