Merge branch 'storage-and-versioning' into 'master'

add versioning and storage

See merge request !1
This commit is contained in:
AJ ONeal 2017-06-14 16:46:22 -06:00
commit 2dda2c8729
1 changed files with 19 additions and 0 deletions

View File

@ -1,6 +1,11 @@
$(function () {
'use strict';
if ('1' !== window.localStorage.getItem('version')) {
window.localStorage.clear();
window.localStorage.setItem('version', '1');
}
var OAUTH3 = window.OAUTH3;
var CONFIG = {
host: OAUTH3.utils.clientUri(window.location)
@ -14,6 +19,20 @@ $(function () {
};
$('.js-scopes-container').html('');
/*
OAUTH3._hooks.sessions.all = function (providerUri) {
};
*/
OAUTH3._hooks = { sessions: {} };
OAUTH3._hooks.sessions.get = function (providerUri, id) {
return JSON.parse(window.localStorage.getItem('session-' + providerUri + (id || '')) || 'null');
};
OAUTH3._hooks.sessions.set = function (providerUri, newSession, id) {
window.localStorage.setItem('session-' + providerUri, JSON.stringify(newSession));
window.localStorage.setItem('session-' + providerUri + (id || newSession.id || newSession.token.id || ''), JSON.stringify(newSession));
return newSession;
};
// TODO let query.parse do location.hash || location.search || location
var clientParams = OAUTH3.query.parse(window.location.hash || window.location.search);
if (/authorization_dialog/.test(window.location.href)) {