From 9d5bf7e1bb813499bf2f4b13187e4293d82e1ccd Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 20 Feb 2020 11:30:38 +0100 Subject: [PATCH 1/4] Disable allow list for files and shared folders --- www/common/inner/access.js | 44 ++++++++++++++++++++++--------------- www/common/proxy-manager.js | 5 +++-- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index f717ad2ef..9acab44ab 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -167,7 +167,6 @@ define([ delete _friends[curve]; } }); - // XXX if no more friends, display message... if (!Object.keys(_friends).length) { $div.append(h('div.cp-app-prop', [ Messages.contacts, @@ -570,7 +569,7 @@ define([ }).filter(function (x) { return x; }); nThen(function (waitFor) { - var msg = Messages.owner_addConfirm; + var msg = Messages.owner_addConfirm; // XXX change to use allow list here UI.confirm(msg, waitFor(function (yes) { if (!yes) { waitFor.abort(); @@ -896,6 +895,10 @@ define([ })); } + // Stop here for files: no allow list, no access request + // Also stop for shared folders + if (parsed.hashData.type !== 'pad' || parsed.type === 'drive') { return h('div', content); } + // Request edit access if (data.roHref && !data.href) { var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right', @@ -940,7 +943,7 @@ define([ var canMute = data.mailbox && owned === true && ( (typeof (data.mailbox) === "string" && data.owners[0] === edPublic) || data.mailbox[edPublic]); - if (owned === true) { // XXX not for files + if (owned === true) { var cbox = UI.createCheckbox('cp-access-mute', Messages.access_muteRequests, !canMute); var $cbox = $(cbox); var spinner = UI.makeSpinner($cbox); @@ -1038,7 +1041,8 @@ define([ Access.getAccessModal = function (common, opts, cb) { var data; var tab1, tab2, tab3; - var owned = false; + var disabled = false; + var allowDisabled = false; var button = [{ className: 'cancel', name: Messages.filePicker_close, @@ -1054,7 +1058,10 @@ define([ data = _data; })); }).nThen(function (waitFor) { - owned = isOwned(common, data); + var owned = isOwned(common, data); + var parsed = Hash.parsePadUrl(data.href || data.roHref); + disabled = !owned || !parsed.hashData || parsed.hashData.type !== 'pad'; + allowDisabled = parsed.type === 'drive'; getAccessTab(common, data, opts, waitFor(function (e, c) { if (e) { @@ -1066,18 +1073,19 @@ define([ }); })); - if (!owned) { return; } - // XXX if "file" ==> don't show "allow" and "owners" + if (disabled) { return; } - getAllowTab(common, data, opts, waitFor(function (e, c) { - if (e) { - waitFor.abort(); - return void cb(e); - } - tab2 = UI.dialog.customModal(c, { - buttons: button - }); - })); + if (!allowDisabled) { + getAllowTab(common, data, opts, waitFor(function (e, c) { + if (e) { + waitFor.abort(); + return void cb(e); + } + tab2 = UI.dialog.customModal(c, { + buttons: button + }); + })); + } getOwnersTab(common, data, opts, waitFor(function (e, c) { if (e) { waitFor.abort(); @@ -1098,12 +1106,12 @@ define([ content: tab1 }, { title: Messages.access_allow, - disabled: !owned, + disabled: disabled || allowDisabled, icon: "fa fa-list", content: tab2 }, { title: Messages.creation_owners, - disabled: !owned, + disabled: disabled, icon: "fa fa-id-badge", content: tab3 }]); diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index 83e10c50c..29f762956 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -900,10 +900,11 @@ define([ cb = cb || function () {}; var sfId = Env.user.userObject.getSFIdFromHref(data.href); if (sfId) { - var sfData = Env.user.proxy[UserObject.SHARED_FOLDERS][sfId]; + var sfData = getSharedFolderData(Env, sfId); + var sfValue = data.attr ? sfData[data.attr] : JSON.parse(JSON.stringify(sfData)); setTimeout(function () { cb(null, { - value: sfData[data.attr], + value: sfValue, atime: 1 }); }); From 5a189862eb79d034126131557f5662c23f999b9e Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 20 Feb 2020 11:31:54 +0100 Subject: [PATCH 2/4] Fix color --- customize.dist/src/less2/include/alertify.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customize.dist/src/less2/include/alertify.less b/customize.dist/src/less2/include/alertify.less index aba088c2e..2960c1c3b 100644 --- a/customize.dist/src/less2/include/alertify.less +++ b/customize.dist/src/less2/include/alertify.less @@ -73,7 +73,7 @@ font: @colortheme_app-font; .cp-checkmark { - color: #000000; + color: @cryptpad_text_col; } .cp-inline-alert-text { From 866ce6fb7d74d781dbaf5729041d328c820c4c11 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 20 Feb 2020 11:43:35 +0100 Subject: [PATCH 3/4] Add translation key --- www/common/inner/access.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 9acab44ab..102fb67dc 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -416,7 +416,8 @@ define([ } }); - // XXX allow_removeConfirm, allow_checkbox, allow_text + // XXX allow_removeConfirm, allow_checkbox, allow_text, allow_addConfirm + Messages.allow_addConfirm = "Are you sure?"; // XXX Messages.allow_removeConfirm = "Are you sure?"; // XXX Messages.allow_checkbox = "Enable allow list"; // XXX Messages.allow_text = 'Pewpewpew'; // XXX @@ -569,7 +570,7 @@ define([ }).filter(function (x) { return x; }); nThen(function (waitFor) { - var msg = Messages.owner_addConfirm; // XXX change to use allow list here + var msg = Messages.allow_addConfirm; UI.confirm(msg, waitFor(function (yes) { if (!yes) { waitFor.abort(); From e6c948febb8a911dbc9b9fc422ac9be9d11dfbcc Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 20 Feb 2020 12:12:22 +0100 Subject: [PATCH 4/4] Display ERESTRICTED error in the UI --- www/common/common-ui-elements.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index fe38c06ed..882f7d027 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -3588,7 +3588,7 @@ define([ }; UIElements.onServerError = function (common, err, toolbar, cb) { - if (["EDELETED", "EEXPIRED"].indexOf(err.type) === -1) { return; } + if (["EDELETED", "EEXPIRED", "ERESTRICTED"].indexOf(err.type) === -1) { return; } var priv = common.getMetadataMgr().getPrivateData(); var msg = err.type; if (err.type === 'EEXPIRED') { @@ -3602,11 +3602,13 @@ define([ if (err.loaded) { msg += Messages.errorCopy; } + } else if (err.type === 'ERESTRICTED') { + msg = Messages.restrictedError || "RESTRICTED"; // XXX } var sframeChan = common.getSframeChannel(); sframeChan.event('EV_SHARE_OPEN', {hidden: true}); if (toolbar && typeof toolbar.deleted === "function") { toolbar.deleted(); } - UI.errorLoadingScreen(msg, true, true); + UI.errorLoadingScreen(msg, Boolean(err.loaded), Boolean(err.loaded)); (cb || function () {})(); };