Fixed Google different oauth scopes after refresh
This commit is contained in:
parent
ffd9953d59
commit
6af6a70f75
@ -1,5 +1,5 @@
|
||||
CACHE MANIFEST
|
||||
#Date Tue Oct 15 2013 01:02:10
|
||||
#Date Tue Oct 15 2013 23:44:34
|
||||
|
||||
CACHE:
|
||||
index.html
|
||||
|
@ -13662,7 +13662,7 @@ define("config", function() {}), define("storage", [ "underscore", "utils" ], fu
|
||||
}
|
||||
}), t;
|
||||
}), define("text!html/settingsExtensionsAccordion.html", [], function() {
|
||||
return '<div class="panel">\n <div class="accordion-heading">\n <div class="checkbox pull-right">\n <label> <input id="input-enable-extension-<%= extensionId %>"\n type="checkbox"<% if(!isOptional) print(\'disabled\') %>>\n enabled\n </label>\n </div>\n <span data-toggle="collapse" data-parent=".accordion-extensions"\n class="accordion-toggle" href="#accordion-extensions-collapse-<%= extensionId %>">\n <%= extensionName %> </span>\n </div>\n <div id="accordion-extensions-collapse-<%= extensionId %>" class="collapse">\n <div class="accordion-inner clearfix"><%= settingsBlock %></div>\n </div>\n</div>\n';
|
||||
return '<div class="panel">\n <div class="accordion-heading">\n <div class="checkbox pull-right">\n <label> <input id="input-enable-extension-<%= extensionId %>"\n type="checkbox"<% if(!isOptional) print(\'disabled\') %>>\n enabled\n </label>\n </div>\n <a data-toggle="collapse" data-parent=".accordion-extensions"\n class="accordion-toggle" href="#accordion-extensions-collapse-<%= extensionId %>">\n <%= extensionName %> </a>\n </div>\n <div id="accordion-extensions-collapse-<%= extensionId %>" class="collapse">\n <div class="accordion-inner clearfix"><%= settingsBlock %></div>\n </div>\n</div>\n';
|
||||
}), function() {
|
||||
var e = function(e, t, n, i) {
|
||||
this.rawMessage = e, this.parsedLine = void 0 !== t ? t : -1, this.snippet = void 0 !== n ? n : null,
|
||||
@ -20364,13 +20364,13 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
||||
var u = void 0;
|
||||
return c.onPagedownConfigure = function(e) {
|
||||
u = document.getElementById("preview-contents");
|
||||
var n = document.querySelectorAll(".table-of-contents"), i = new RegExp("^" + c.config.marker + "$", "g");
|
||||
var n = new RegExp("^" + c.config.marker + "$", "g");
|
||||
e.hooks.chain("onPreviewRefresh", function() {
|
||||
var e = l();
|
||||
t.each(u.getElementsByTagName("p"), function(t) {
|
||||
i.test(t.innerHTML) && (t.innerHTML = e);
|
||||
}), t.each(n, function(t) {
|
||||
t.innerHTML = e;
|
||||
var e = document.querySelectorAll(".table-of-contents, .toc"), i = l();
|
||||
t.each(u.getElementsByTagName("p"), function(e) {
|
||||
n.test(e.innerHTML) && (e.innerHTML = i);
|
||||
}), t.each(e, function(e) {
|
||||
e.innerHTML = i;
|
||||
});
|
||||
});
|
||||
}, c;
|
||||
@ -26926,32 +26926,32 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
||||
}), void 0);
|
||||
});
|
||||
}
|
||||
function l(t, i) {
|
||||
function l(t, i, o) {
|
||||
t.onRun(function() {
|
||||
function o() {
|
||||
function r() {
|
||||
n.redirectConfirm("You are being redirected to <strong>Google</strong> authorization page.", function() {
|
||||
t.chain(r);
|
||||
t.chain(s);
|
||||
}, function() {
|
||||
t.error(new Error("Operation canceled."));
|
||||
});
|
||||
}
|
||||
function r() {
|
||||
s === !1 && (t.timeout = ASYNC_TASK_LONG_TIMEOUT);
|
||||
var n = e.chain(g).pick(e.keys(h).concat([ i ])).flatten().value();
|
||||
function s() {
|
||||
a === !1 && (t.timeout = ASYNC_TASK_LONG_TIMEOUT);
|
||||
var n = e.chain(g).pick(h.getListWithNew(i)).flatten().value();
|
||||
gapi.auth.authorize({
|
||||
client_id: GOOGLE_CLIENT_ID,
|
||||
scope: n,
|
||||
immediate: s
|
||||
immediate: a
|
||||
}, function(e) {
|
||||
gapi.client.load("drive", "v2", function() {
|
||||
return !e || e.error ? d === !0 && s === !0 ? (s = !1, t.chain(o), void 0) : (t.error(new Error("Access to Google account is not authorized.")),
|
||||
void 0) : (h[i] = !0, t.chain(), void 0);
|
||||
return !e || e.error ? d === !0 && a === !0 ? (a = !1, t.chain(r), void 0) : (t.error(new Error("Access to Google account is not authorized.")),
|
||||
void 0) : (h.add(i), t.chain(), void 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (e.has(h, i)) return t.chain(), void 0;
|
||||
var s = !0;
|
||||
t.chain(r);
|
||||
if (!o && h.isAuthorized(i)) return t.chain(), void 0;
|
||||
var a = !0;
|
||||
t.chain(s);
|
||||
});
|
||||
}
|
||||
function c(e, t) {
|
||||
@ -26959,9 +26959,9 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
||||
if (e) if (logger.error(e), "string" == typeof e) i = e; else {
|
||||
if (i = "Google error (" + e.code + ": " + e.message + ").", e.code >= 500 && e.code < 600) return t.retry(new Error(i)),
|
||||
void 0;
|
||||
if (401 === e.code || 403 === e.code || "token_refresh_required" == e.code) return h = {},
|
||||
if (401 === e.code || 403 === e.code || "token_refresh_required" == e.code) return h.reset(),
|
||||
i = "Access to Google account is not authorized.", t.retry(new Error(i), 1), void 0;
|
||||
(0 === e.code || -1 === e.code) && (d = !1, h = {}, n.setOffline(), i = "|stopPublish");
|
||||
(0 === e.code || -1 === e.code) && (d = !1, h.reset(), n.setOffline(), i = "|stopPublish");
|
||||
}
|
||||
t.error(new Error(i));
|
||||
}
|
||||
@ -26989,7 +26989,23 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
||||
}), void 0);
|
||||
});
|
||||
}
|
||||
var d = !1, h = {}, p = {}, f = !1;
|
||||
var d = !1, h = {};
|
||||
(function() {
|
||||
var t = {}, n = !1;
|
||||
e.each((localStorage.gdrivePermissions || "").split(";"), function(e) {
|
||||
e && (t[e] = !0);
|
||||
}), h.reset = function() {
|
||||
n = !1;
|
||||
}, h.isAuthorized = function(i) {
|
||||
return n && e.has(t, i);
|
||||
}, h.add = function(i) {
|
||||
t[i] = !0, localStorage.gdrivePermissions = e.keys(t).join(";"), n = !0;
|
||||
}, h.getListWithNew = function(n) {
|
||||
var i = e.keys(t);
|
||||
return e.has(t, n) || i.push(n), i;
|
||||
};
|
||||
})();
|
||||
var p = {}, f = !1;
|
||||
r.addListener("onOfflineChanged", function(e) {
|
||||
f = e;
|
||||
});
|
||||
@ -26999,9 +27015,8 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
||||
picasa: [ "https://picasaweb.google.com/data/" ]
|
||||
};
|
||||
p.forceGdriveAuthenticate = function() {
|
||||
h = e.omit(h, "gdrive");
|
||||
var t = new s();
|
||||
a(t), l(t, "gdrive"), t.enqueue();
|
||||
var e = new s();
|
||||
a(e), l(e, "gdrive", !0), e.enqueue();
|
||||
}, p.upload = function(e, t, n, o, r, u, d) {
|
||||
var h = void 0, p = new s();
|
||||
a(p), l(p, "gdrive"), p.onRun(function() {
|
||||
|
@ -1546,8 +1546,6 @@ a{-webkit-transition:background-color ease-in-out .15s,color ease-in-out .15s,bo
|
||||
.modal-settings textarea{max-width:100%;min-height:100px}
|
||||
.modal-settings .panel{border:0;border-radius:inherit;background:#ffffff;border-bottom:1px solid #f0f3f4;-webkit-box-shadow:none;box-shadow:none}
|
||||
.modal-settings .accordion-heading{padding:12px 15px}
|
||||
.modal-settings .accordion-heading .accordion-toggle{display:inline;padding:0;font-weight:bold;cursor:pointer}
|
||||
.modal-settings .accordion-heading .accordion-toggle:hover{text-decoration:underline}
|
||||
.modal-settings .accordion-heading .checkbox{margin-top:0;margin-bottom:0}
|
||||
.modal-settings .accordion-inner{border:0;padding:10px 40px 20px}
|
||||
.modal-settings .accordion-inner .form-horizontal .control-label{text-align:left}
|
||||
|
@ -1546,8 +1546,6 @@ a{-webkit-transition:background-color ease-in-out .15s,color ease-in-out .15s,bo
|
||||
.modal-settings textarea{max-width:100%;min-height:100px}
|
||||
.modal-settings .panel{border:0;border-radius:inherit;background:#ffffff;border-bottom:1px solid #f1f1f1;-webkit-box-shadow:none;box-shadow:none}
|
||||
.modal-settings .accordion-heading{padding:12px 15px}
|
||||
.modal-settings .accordion-heading .accordion-toggle{display:inline;padding:0;font-weight:bold;cursor:pointer}
|
||||
.modal-settings .accordion-heading .accordion-toggle:hover{text-decoration:underline}
|
||||
.modal-settings .accordion-heading .checkbox{margin-top:0;margin-bottom:0}
|
||||
.modal-settings .accordion-inner{border:0;padding:10px 40px 20px}
|
||||
.modal-settings .accordion-inner .form-horizontal .control-label{text-align:left}
|
||||
|
@ -1546,8 +1546,6 @@ a{-webkit-transition:background-color ease-in-out .15s,color ease-in-out .15s,bo
|
||||
.modal-settings textarea{max-width:100%;min-height:100px}
|
||||
.modal-settings .panel{border:0;border-radius:inherit;background:#323232;border-bottom:1px solid #444444;-webkit-box-shadow:none;box-shadow:none}
|
||||
.modal-settings .accordion-heading{padding:12px 15px}
|
||||
.modal-settings .accordion-heading .accordion-toggle{display:inline;padding:0;font-weight:bold;cursor:pointer}
|
||||
.modal-settings .accordion-heading .accordion-toggle:hover{text-decoration:underline}
|
||||
.modal-settings .accordion-heading .checkbox{margin-top:0;margin-bottom:0}
|
||||
.modal-settings .accordion-inner{border:0;padding:10px 40px 20px}
|
||||
.modal-settings .accordion-inner .form-horizontal .control-label{text-align:left}
|
||||
|
@ -1546,8 +1546,6 @@ a{-webkit-transition:background-color ease-in-out .15s,color ease-in-out .15s,bo
|
||||
.modal-settings textarea{max-width:100%;min-height:100px}
|
||||
.modal-settings .panel{border:0;border-radius:inherit;background:#ffffff;border-bottom:1px solid #ede9e6;-webkit-box-shadow:none;box-shadow:none}
|
||||
.modal-settings .accordion-heading{padding:12px 15px}
|
||||
.modal-settings .accordion-heading .accordion-toggle{display:inline;padding:0;font-weight:bold;cursor:pointer}
|
||||
.modal-settings .accordion-heading .accordion-toggle:hover{text-decoration:underline}
|
||||
.modal-settings .accordion-heading .checkbox{margin-top:0;margin-bottom:0}
|
||||
.modal-settings .accordion-inner{border:0;padding:10px 40px 20px}
|
||||
.modal-settings .accordion-inner .form-horizontal .control-label{text-align:left}
|
||||
|
@ -10,7 +10,32 @@ define([
|
||||
], function(_, $, core, utils, settings, eventMgr, AsyncTask) {
|
||||
|
||||
var connected = false;
|
||||
var authorizationMgr = {};
|
||||
(function() {
|
||||
var permissionList = {};
|
||||
var isAuthorized = false;
|
||||
_.each((localStorage.gdrivePermissions || '').split(';'), function(permission) {
|
||||
permission && (permissionList[permission] = true);
|
||||
});
|
||||
authorizationMgr.reset = function() {
|
||||
isAuthorized = false;
|
||||
};
|
||||
authorizationMgr.isAuthorized = function(permission) {
|
||||
return isAuthorized && _.has(permissionList, permission);
|
||||
};
|
||||
authorizationMgr.add = function(permission) {
|
||||
permissionList[permission] = true;
|
||||
localStorage.gdrivePermissions = _.keys(permissionList).join(';');
|
||||
isAuthorized = true;
|
||||
};
|
||||
authorizationMgr.getListWithNew = function(permission) {
|
||||
var result = _.keys(permissionList);
|
||||
if(!_.has(permissionList, permission)) {
|
||||
result.push(permission);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
|
||||
var googleHelper = {};
|
||||
|
||||
@ -65,9 +90,9 @@ define([
|
||||
'https://picasaweb.google.com/data/'
|
||||
]
|
||||
};
|
||||
function authenticate(task, permission) {
|
||||
function authenticate(task, permission, force) {
|
||||
task.onRun(function() {
|
||||
if(_.has(permissionList, permission)) {
|
||||
if(!force && authorizationMgr.isAuthorized(permission)) {
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
@ -83,7 +108,7 @@ define([
|
||||
if(immediate === false) {
|
||||
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
|
||||
}
|
||||
var scopeList = _.chain(scopeMap).pick(_.keys(permissionList).concat([permission])).flatten().value();
|
||||
var scopeList = _.chain(scopeMap).pick(authorizationMgr.getListWithNew(permission)).flatten().value();
|
||||
gapi.auth.authorize({
|
||||
'client_id': GOOGLE_CLIENT_ID,
|
||||
'scope': scopeList,
|
||||
@ -103,7 +128,7 @@ define([
|
||||
return;
|
||||
}
|
||||
// Success
|
||||
permissionList[permission] = true;
|
||||
authorizationMgr.add(permission);
|
||||
task.chain();
|
||||
});
|
||||
});
|
||||
@ -112,10 +137,9 @@ define([
|
||||
});
|
||||
}
|
||||
googleHelper.forceGdriveAuthenticate = function() {
|
||||
permissionList = _.omit(permissionList, 'gdrive') ;
|
||||
var task = new AsyncTask();
|
||||
connect(task);
|
||||
authenticate(task, 'gdrive');
|
||||
authenticate(task, 'gdrive', true);
|
||||
task.enqueue();
|
||||
};
|
||||
|
||||
@ -572,14 +596,14 @@ define([
|
||||
return;
|
||||
}
|
||||
else if(error.code === 401 || error.code === 403 || error.code == "token_refresh_required") {
|
||||
permissionList = {};
|
||||
authorizationMgr.reset();
|
||||
errorMsg = "Access to Google account is not authorized.";
|
||||
task.retry(new Error(errorMsg), 1);
|
||||
return;
|
||||
}
|
||||
else if(error.code === 0 || error.code === -1) {
|
||||
connected = false;
|
||||
permissionList = {};
|
||||
authorizationMgr.reset();
|
||||
core.setOffline();
|
||||
errorMsg = "|stopPublish";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user