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