From d59bc4612ddef1c97fe03392539374efd6f03fad Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 12 Jan 2018 15:54:36 +0100 Subject: [PATCH] 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);