Fixed Google multiple permissions management
This commit is contained in:
parent
c184465ce6
commit
94ad187c91
@ -1,5 +1,5 @@
|
|||||||
CACHE MANIFEST
|
CACHE MANIFEST
|
||||||
#Date Sun Oct 13 2013 23:45:27
|
#Date Mon Oct 14 2013 00:32:24
|
||||||
|
|
||||||
CACHE:
|
CACHE:
|
||||||
index.html
|
index.html
|
||||||
|
@ -14941,7 +14941,7 @@ define("config", function() {}), define("storage", [ "underscore", "utils" ], fu
|
|||||||
var i = (n.dataTransfer || n.target).files;
|
var i = (n.dataTransfer || n.target).files;
|
||||||
e(".modal-import-harddrive-markdown, .modal-import-harddrive-html").modal("hide"),
|
e(".modal-import-harddrive-markdown, .modal-import-harddrive-html").modal("hide"),
|
||||||
t.each(i, function(t) {
|
t.each(i, function(t) {
|
||||||
if (!e(n.target).is("#wmd-input *") || !t.name.match(/.(jpe?g|png|gif)$/)) {
|
if (!e(n.target).is("#wmd-input *") || !t.name.match(/.(jpe?g|png|gif)$/i)) {
|
||||||
var i = new FileReader();
|
var i = new FileReader();
|
||||||
i.onload = function(e) {
|
i.onload = function(e) {
|
||||||
return function(t) {
|
return function(t) {
|
||||||
@ -26924,30 +26924,30 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
|||||||
}
|
}
|
||||||
function l(t, i) {
|
function l(t, i) {
|
||||||
t.onRun(function() {
|
t.onRun(function() {
|
||||||
function r() {
|
function o() {
|
||||||
n.redirectConfirm("You are being redirected to <strong>Google</strong> authorization page.", function() {
|
n.redirectConfirm("You are being redirected to <strong>Google</strong> authorization page.", function() {
|
||||||
t.chain(s);
|
t.chain(r);
|
||||||
}, function() {
|
}, function() {
|
||||||
t.error(new Error("Operation canceled."));
|
t.error(new Error("Operation canceled."));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function s() {
|
function r() {
|
||||||
l === !1 && (t.timeout = ASYNC_TASK_LONG_TIMEOUT), gapi.auth.authorize({
|
s === !1 && (t.timeout = ASYNC_TASK_LONG_TIMEOUT);
|
||||||
|
var n = e.chain(g).pick(e.keys(h).concat([ i ])).flatten().value();
|
||||||
|
gapi.auth.authorize({
|
||||||
client_id: GOOGLE_CLIENT_ID,
|
client_id: GOOGLE_CLIENT_ID,
|
||||||
scope: a,
|
scope: n,
|
||||||
immediate: l
|
immediate: s
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
gapi.client.load("drive", "v2", function() {
|
gapi.client.load("drive", "v2", function() {
|
||||||
return !e || e.error ? d === !0 && l === !0 ? (l = !1, t.chain(r), void 0) : (t.error(new Error("Access to Google account is not authorized.")),
|
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);
|
void 0) : (h[i] = !0, t.chain(), void 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (e.has(h, i)) return t.chain(), void 0;
|
if (e.has(h, i)) return t.chain(), void 0;
|
||||||
var a = void 0;
|
var s = !0;
|
||||||
"gdrive" == i && o.gdriveFullAccess === !0 ? a = [ "https://www.googleapis.com/auth/drive.install", "https://www.googleapis.com/auth/drive" ] : "gdrive" == i && o.gdriveFullAccess === !1 ? a = [ "https://www.googleapis.com/auth/drive.install", "https://www.googleapis.com/auth/drive.file" ] : "blogger" == i ? a = [ "https://www.googleapis.com/auth/blogger" ] : "picasa" == i && (a = [ "https://picasaweb.google.com/data/" ]);
|
t.chain(r);
|
||||||
var l = !0;
|
|
||||||
t.chain(s);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function c(e, t) {
|
function c(e, t) {
|
||||||
@ -26963,7 +26963,7 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
|||||||
}
|
}
|
||||||
function u(e) {
|
function u(e) {
|
||||||
e.onRun(function() {
|
e.onRun(function() {
|
||||||
return g === !0 ? (e.chain(), void 0) : (t.ajax({
|
return m === !0 ? (e.chain(), void 0) : (t.ajax({
|
||||||
url: "//www.google.com/jsapi",
|
url: "//www.google.com/jsapi",
|
||||||
data: {
|
data: {
|
||||||
key: GOOGLE_API_KEY
|
key: GOOGLE_API_KEY
|
||||||
@ -26975,7 +26975,7 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
|||||||
callback: function() {
|
callback: function() {
|
||||||
e.chain();
|
e.chain();
|
||||||
}
|
}
|
||||||
}), g = !0;
|
}), m = !0;
|
||||||
}).fail(function(t) {
|
}).fail(function(t) {
|
||||||
var n = {
|
var n = {
|
||||||
code: t.status,
|
code: t.status,
|
||||||
@ -26988,7 +26988,13 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
|||||||
var d = !1, h = {}, p = {}, f = !1;
|
var d = !1, h = {}, p = {}, f = !1;
|
||||||
r.addListener("onOfflineChanged", function(e) {
|
r.addListener("onOfflineChanged", function(e) {
|
||||||
f = e;
|
f = e;
|
||||||
}), p.forceGdriveAuthenticate = function() {
|
});
|
||||||
|
var g = {
|
||||||
|
gdrive: [ "https://www.googleapis.com/auth/drive.install", o.gdriveFullAccess === !0 ? "https://www.googleapis.com/auth/drive" : "https://www.googleapis.com/auth/drive.file" ],
|
||||||
|
blogger: [ "https://www.googleapis.com/auth/blogger" ],
|
||||||
|
picasa: [ "https://picasaweb.google.com/data/" ]
|
||||||
|
};
|
||||||
|
p.forceGdriveAuthenticate = function() {
|
||||||
h = e.omit(h, "gdrive");
|
h = e.omit(h, "gdrive");
|
||||||
var t = new s();
|
var t = new s();
|
||||||
a(t), l(t, "gdrive"), t.enqueue();
|
a(t), l(t, "gdrive"), t.enqueue();
|
||||||
@ -27206,7 +27212,7 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
|||||||
n(e);
|
n(e);
|
||||||
}), r.enqueue();
|
}), r.enqueue();
|
||||||
};
|
};
|
||||||
var g = !1;
|
var m = !1;
|
||||||
return p.picker = function(e, n) {
|
return p.picker = function(e, n) {
|
||||||
function o() {
|
function o() {
|
||||||
void 0 !== l && (l.setVisible(!1), t(".modal-backdrop, .picker").remove());
|
void 0 !== l && (l.setVisible(!1), t(".modal-backdrop, .picker").remove());
|
||||||
@ -28341,7 +28347,7 @@ if (hljs.LANGUAGES.glsl = function(e) {
|
|||||||
return o.addListener("onReady", function() {
|
return o.addListener("onReady", function() {
|
||||||
function n(n) {
|
function n(n) {
|
||||||
var o = (n.dataTransfer || n.target).files, r = t.first(o);
|
var o = (n.dataTransfer || n.target).files, r = t.first(o);
|
||||||
if (r.name.match(/.(jpe?g|png|gif)$/)) {
|
if (r.name.match(/.(jpe?g|png|gif)$/i)) {
|
||||||
n.stopPropagation(), n.preventDefault();
|
n.stopPropagation(), n.preventDefault();
|
||||||
var a = new FileReader();
|
var a = new FileReader();
|
||||||
a.onload = function() {
|
a.onload = function() {
|
||||||
|
@ -30,7 +30,7 @@ define([
|
|||||||
var files = (evt.dataTransfer || evt.target).files;
|
var files = (evt.dataTransfer || evt.target).files;
|
||||||
$(".modal-import-harddrive-markdown, .modal-import-harddrive-html").modal("hide");
|
$(".modal-import-harddrive-markdown, .modal-import-harddrive-html").modal("hide");
|
||||||
_.each(files, function(file) {
|
_.each(files, function(file) {
|
||||||
if($(evt.target).is("#wmd-input *") && file.name.match(/.(jpe?g|png|gif)$/)) {
|
if($(evt.target).is("#wmd-input *") && file.name.match(/.(jpe?g|png|gif)$/i)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
@ -53,35 +53,24 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to authenticate with Oauth
|
// Try to authenticate with Oauth
|
||||||
|
var scopeMap = {
|
||||||
|
gdrive: [
|
||||||
|
'https://www.googleapis.com/auth/drive.install',
|
||||||
|
settings.gdriveFullAccess === true ? 'https://www.googleapis.com/auth/drive' : 'https://www.googleapis.com/auth/drive.file'
|
||||||
|
],
|
||||||
|
blogger: [
|
||||||
|
'https://www.googleapis.com/auth/blogger'
|
||||||
|
],
|
||||||
|
picasa: [
|
||||||
|
'https://picasaweb.google.com/data/'
|
||||||
|
]
|
||||||
|
};
|
||||||
function authenticate(task, permission) {
|
function authenticate(task, permission) {
|
||||||
task.onRun(function() {
|
task.onRun(function() {
|
||||||
if(_.has(permissionList, permission)) {
|
if(_.has(permissionList, permission)) {
|
||||||
task.chain();
|
task.chain();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var scopes = undefined;
|
|
||||||
if(permission == 'gdrive' && settings.gdriveFullAccess === true) {
|
|
||||||
scopes = [
|
|
||||||
"https://www.googleapis.com/auth/drive.install",
|
|
||||||
"https://www.googleapis.com/auth/drive",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
else if(permission == 'gdrive' && settings.gdriveFullAccess === false) {
|
|
||||||
scopes = [
|
|
||||||
"https://www.googleapis.com/auth/drive.install",
|
|
||||||
"https://www.googleapis.com/auth/drive.file",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
else if(permission == 'blogger') {
|
|
||||||
scopes = [
|
|
||||||
"https://www.googleapis.com/auth/blogger",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
else if(permission == 'picasa') {
|
|
||||||
scopes = [
|
|
||||||
"https://picasaweb.google.com/data/",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
var immediate = true;
|
var immediate = true;
|
||||||
function oauthRedirect() {
|
function oauthRedirect() {
|
||||||
core.redirectConfirm('You are being redirected to <strong>Google</strong> authorization page.', function() {
|
core.redirectConfirm('You are being redirected to <strong>Google</strong> authorization page.', function() {
|
||||||
@ -94,9 +83,10 @@ define([
|
|||||||
if(immediate === false) {
|
if(immediate === false) {
|
||||||
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
|
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
var scopeList = _.chain(scopeMap).pick(_.keys(permissionList).concat([permission])).flatten().value();
|
||||||
gapi.auth.authorize({
|
gapi.auth.authorize({
|
||||||
'client_id': GOOGLE_CLIENT_ID,
|
'client_id': GOOGLE_CLIENT_ID,
|
||||||
'scope': scopes,
|
'scope': scopeList,
|
||||||
'immediate': immediate
|
'immediate': immediate
|
||||||
}, function(authResult) {
|
}, function(authResult) {
|
||||||
gapi.client.load('drive', 'v2', function() {
|
gapi.client.load('drive', 'v2', function() {
|
||||||
|
@ -38,7 +38,7 @@ define([
|
|||||||
function handleImgImport(evt) {
|
function handleImgImport(evt) {
|
||||||
var files = (evt.dataTransfer || evt.target).files;
|
var files = (evt.dataTransfer || evt.target).files;
|
||||||
var file = _.first(files);
|
var file = _.first(files);
|
||||||
if(file.name.match(/.(jpe?g|png|gif)$/)) {
|
if(file.name.match(/.(jpe?g|png|gif)$/i)) {
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
Loading…
Reference in New Issue
Block a user