bugfix base64 replacement, session retrieval
This commit is contained in:
		
							parent
							
								
									eff1fd1127
								
							
						
					
					
						commit
						96a105c5f2
					
				| @ -38,9 +38,10 @@ | |||||||
|     , encodeUrlSafe: function (b64) { |     , encodeUrlSafe: function (b64) { | ||||||
|         // for directive passing in .well-known/oauth3
 |         // for directive passing in .well-known/oauth3
 | ||||||
|         // Base64 to URL-safe Base64
 |         // Base64 to URL-safe Base64
 | ||||||
|  |         b64 = OAUTH3._base64.btoa(b64); | ||||||
|         b64 = b64.replace(/\+/g, '-').replace(/\//g, '_'); |         b64 = b64.replace(/\+/g, '-').replace(/\//g, '_'); | ||||||
|         b64 = b64.replace(/=+/g, ''); |         b64 = b64.replace(/=+/g, ''); | ||||||
|         return OAUTH3._base64.btoa(b64); |         return b64; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   , uri: { |   , uri: { | ||||||
| @ -510,7 +511,7 @@ | |||||||
|         } |         } | ||||||
|       , _getCached: function (providerUri) { |       , _getCached: function (providerUri) { | ||||||
|           providerUri = OAUTH3.uri.normalize(providerUri); |           providerUri = OAUTH3.uri.normalize(providerUri); | ||||||
|           return OAUTH3.hooks.session._sessions[providerUri]; |           return OAUTH3.hooks.session._cache[providerUri]; | ||||||
|         } |         } | ||||||
|       , set: function (providerUri, newSession) { |       , set: function (providerUri, newSession) { | ||||||
|           if (!providerUri) { |           if (!providerUri) { | ||||||
| @ -518,8 +519,8 @@ | |||||||
|             throw new Error("providerUri is not set"); |             throw new Error("providerUri is not set"); | ||||||
|           } |           } | ||||||
|           providerUri = OAUTH3.uri.normalize(providerUri); |           providerUri = OAUTH3.uri.normalize(providerUri); | ||||||
|           if (!OAUTH3.hooks.session._sessions) { OAUTH3.hooks.session._sessions = {}; } |           if (!OAUTH3.hooks.session._cache) { OAUTH3.hooks.session._cache = {}; } | ||||||
|           OAUTH3.hooks.session._sessions[providerUri] = newSession; |           OAUTH3.hooks.session._cache[providerUri] = newSession; | ||||||
|           return OAUTH3.PromiseA.resolve(OAUTH3.hooks.session._set(providerUri, newSession)); |           return OAUTH3.PromiseA.resolve(OAUTH3.hooks.session._set(providerUri, newSession)); | ||||||
|         } |         } | ||||||
|       , get: function (providerUri) { |       , get: function (providerUri) { | ||||||
| @ -527,10 +528,13 @@ | |||||||
|           if (!providerUri) { |           if (!providerUri) { | ||||||
|             throw new Error("providerUri is not set"); |             throw new Error("providerUri is not set"); | ||||||
|           } |           } | ||||||
|           if (!OAUTH3.hooks.session._sessions) { OAUTH3.hooks.session._sessions = {}; } |           if (!OAUTH3.hooks.session._cache) { OAUTH3.hooks.session._cache = {}; } | ||||||
| 
 | 
 | ||||||
|           return OAUTH3.PromiseA.resolve(OAUTH3.hooks.session._sessions[providerUri] |           return OAUTH3.PromiseA.resolve(OAUTH3.hooks.session._cache[providerUri] | ||||||
|             || OAUTH3.hooks.session._get(providerUri) || null); |             || OAUTH3.hooks.session._get(providerUri)).then(function (session) { | ||||||
|  |             OAUTH3.hooks.session._cache[providerUri] = session; | ||||||
|  |             return session; | ||||||
|  |           }); | ||||||
|         } |         } | ||||||
|       , _get: function (providerUri) { |       , _get: function (providerUri) { | ||||||
|           console.warn('[Warn] Please implement OAUTH3.hooks.session._get = function (providerUri) { return PromiseA<savedSession>; }'); |           console.warn('[Warn] Please implement OAUTH3.hooks.session._get = function (providerUri) { return PromiseA<savedSession>; }'); | ||||||
| @ -1036,8 +1040,16 @@ | |||||||
|           }); |           }); | ||||||
|         }); |         }); | ||||||
|       } |       } | ||||||
|  |     , checkSession: function () { | ||||||
|  |         return OAUTH3.hooks.session.get(this._providerUri); | ||||||
|  |       } | ||||||
|     , login: function (opts) { |     , login: function (opts) { | ||||||
|         var me = this; |         var me = this; | ||||||
|  |         if (me.session()) { | ||||||
|  |           me._session = true; | ||||||
|  |           return OAUTH3.PromiseA.resolve(me.session()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         opts = opts || {}; |         opts = opts || {}; | ||||||
|         opts.client_uri = me._clientUri; |         opts.client_uri = me._clientUri; | ||||||
| 
 | 
 | ||||||
| @ -1047,7 +1059,7 @@ | |||||||
|         }); |         }); | ||||||
|       } |       } | ||||||
|     , session: function () { |     , session: function () { | ||||||
|         return JSON.parse(JSON.stringify(OAUTH3.hooks.session._getCached(this._providerUri))); |         return JSON.parse(JSON.stringify(OAUTH3.hooks.session._getCached(this._providerUri) || {})); | ||||||
|       } |       } | ||||||
|     , request: function (preq, opts) { |     , request: function (preq, opts) { | ||||||
|         opts = opts || {}; |         opts = opts || {}; | ||||||
|  | |||||||
| @ -1 +0,0 @@ | |||||||
| oauth3.core.js |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user