From d59bc4612ddef1c97fe03392539374efd6f03fad Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 12 Jan 2018 15:54:36 +0100 Subject: [PATCH 1/5] Ability to disable the drive for anonymous users --- customize.dist/application_config.js | 2 ++ customize.dist/translations/messages.fr.js | 2 ++ customize.dist/translations/messages.js | 1 + www/common/outer/async-store.js | 5 ++++- www/drive/inner.js | 4 ++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index 0762b5b36..f7790ad66 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -68,5 +68,7 @@ define(function() { config.displayCreationScreen = false; + config.disableAnonymousStore = true; + return config; }); diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 8ff3c8de7..869064a8b 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -29,6 +29,8 @@ define(function () { out.typeError = "Ce pad n'est pas compatible avec l'application sélectionnée"; out.onLogout = 'Vous êtes déconnecté de votre compte utilisateur, cliquez ici pour vous authentifier
ou appuyez sur Échap pour accéder au pad en mode lecture seule.'; out.wrongApp = "Impossible d'afficher le contenu de ce document temps-réel dans votre navigateur. Vous pouvez essayer de recharger la page."; + out.padNotPinned = 'Ce pad va expirer dans 3 mois, {0}connectez-vous{1} ou {2}enregistrez-vous{3} pour le préserver.'; + out.anonymousStoreDisabled = "L'administrateur de cette instance de CryptPad a désactivé le drive pour les utilisateurs non enregistrés. Vous devez vous connecter pour pouvoir utiliser CryptDrive."; out.loading = "Chargement..."; out.error = "Erreur"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index a877275fd..6ac63c4ef 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -32,6 +32,7 @@ define(function () { out.onLogout = 'You are logged out, click here to log in
or press Escape to access your pad in read-only mode.'; out.wrongApp = "Unable to display the content of that realtime session in your browser. Please try to reload that page."; out.padNotPinned = 'This pad will expire in 3 months, {0}login{1} or {2}register{3} to preserve it.'; + out.anonymousStoreDisabled = "The webmaster of this CryptPad instance has disabled the store for anonymous users. You have to log in to be able to use CryptDrive."; out.loading = "Loading..."; out.error = "Error"; diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 7d3d15dfd..82cbee00d 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -10,12 +10,13 @@ define([ '/common/common-messenger.js', '/common/outer/chainpad-netflux-worker.js', '/common/outer/network-config.js', + '/customize/application_config.js', '/bower_components/chainpad-crypto/crypto.js?v=0.1.5', '/bower_components/chainpad/chainpad.dist.js', '/bower_components/chainpad-listmap/chainpad-listmap.js', ], function (UserObject, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger, - CpNfWorker, NetConfig, + CpNfWorker, NetConfig, AppConfig, Crypto, ChainPad, Listmap) { var Store = {}; @@ -524,6 +525,8 @@ define([ var p = Hash.parsePadUrl(href); var h = p.hashData; + if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); } + var owners; if (Store.channel && Store.channel.wc && Util.base64ToHex(h.channel) === Store.channel.wc.id) { owners = Store.channel.data.owners || undefined; diff --git a/www/drive/inner.js b/www/drive/inner.js index afa12fdec..dfc330420 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1922,6 +1922,10 @@ define([ }; var displayAllFiles = function ($container) { + if (AppConfig.disableAnonymousStore && !APP.loggedIn) { + $container.append(Messages.anonymousStoreDisabled); + return; + } var allfiles = files[FILES_DATA]; if (allfiles.length === 0) { return; } var $fileHeader = getFileListHeader(false); From a4b35728dc478b3819569c251078be76dc4b04d3 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 12 Jan 2018 17:08:41 +0100 Subject: [PATCH 2/5] Todo app has a hash in the omnibar --- www/common/sframe-common-outer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 3f9960085..55346db6a 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -578,7 +578,7 @@ define([ window.location.hash = hash; }; - var cfg = { + var cpNfCfg = { sframeChan: sframeChan, channel: secret.channel, padRpc: Cryptpad.padRpc, @@ -599,9 +599,9 @@ define([ } }; Object.keys(rtConfig).forEach(function (k) { - cfg[k] = rtConfig[k]; + cpNfCfg[k] = rtConfig[k]; }); - CpNfOuter.start(cfg); + CpNfOuter.start(cpNfCfg); }; sframeChan.on('Q_CREATE_PAD', function (data, cb) { From dffa117f4da2d816ab9ff57b781d690b934e862c Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 12 Jan 2018 17:09:33 +0100 Subject: [PATCH 3/5] lint compliance --- customize.dist/src/less2/include/icons.less | 1 - 1 file changed, 1 deletion(-) diff --git a/customize.dist/src/less2/include/icons.less b/customize.dist/src/less2/include/icons.less index 85516371a..a79bc25f5 100644 --- a/customize.dist/src/less2/include/icons.less +++ b/customize.dist/src/less2/include/icons.less @@ -27,7 +27,6 @@ } .fa { display: block; - margin: auto; font-size: 64px; margin: 18px 0; text-align: center; From 85edc028ff83b489f184da93ca1b2f66ee5b7fcb Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 12 Jan 2018 17:10:55 +0100 Subject: [PATCH 4/5] Remove logging about filepicker rpc --- www/filepicker/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/www/filepicker/main.js b/www/filepicker/main.js index 8b7ab2b60..596cc0a45 100644 --- a/www/filepicker/main.js +++ b/www/filepicker/main.js @@ -74,7 +74,6 @@ define([ config.addCommonRpc(sframeChan); sframeChan.on('Q_GET_FILES_LIST', function (types, cb) { - console.error("TODO: make sure Q_GET_FILES_LIST is only available from filepicker"); Cryptpad.getSecureFilesList(types, function (err, data) { cb({ error: err, From a40315aff7b4376d811e93ee70058b90f7670ebd Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 12 Jan 2018 17:15:11 +0100 Subject: [PATCH 5/5] Remove ability to delete comments in polls for readonly users --- www/poll/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/poll/inner.js b/www/poll/inner.js index ccddcef19..dd585ec31 100644 --- a/www/poll/inner.js +++ b/www/poll/inner.js @@ -751,7 +751,7 @@ define([ }).appendTo($msg); // Actions - if (!c.profile || c.profile === profile) { + if (!APP.readOnly && (!c.profile || c.profile === profile)) { $('