From 206ac144380bea625463760d5a3261ef3c6e4cdc Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Apr 2018 18:54:46 +0200 Subject: [PATCH] Prevent users from creating a pad when visiting a deleted profile (read-only mode) --- customize.dist/translations/messages.fr.js | 1 + customize.dist/translations/messages.js | 1 + www/common/sframe-common-outer.js | 6 ++++++ www/common/sframe-common.js | 9 +++++++++ www/common/sframe-protocol.js | 3 +++ 5 files changed, 20 insertions(+) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 05845a83c..86f960bcb 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -37,6 +37,7 @@ define(function () { out.chainpadError = 'Une erreur critique est survenue lors de la mise à jour du contenu. Le pad est désormais en mode lecture seule afin de s\'assurer que vous ne perdiez pas davantage de données.
' + 'Appuyez sur Échap pour voir le pad ou rechargez la page pour pouvoir le modifier à nouveau.'; out.errorCopy = ' Vous pouvez toujours copier son contenu ailleurs en appuyant sur Échap.
Dés que vous aurez quitté la page, il sera impossible de le récupérer.'; + out.errorRedirectToHome = 'Appuyez sur Échap pour retourner vers votre CryptDrive.'; out.loading = "Chargement..."; out.error = "Erreur"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index ce2868783..ddaa1158f 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -38,6 +38,7 @@ define(function () { out.chainpadError = 'A critical error occurred when updating your content. This page is in read-only mode to make sure you won\'t lose your work.
' + 'Hit Esc to continue to view this pad, or reload to try editing again.'; out.errorCopy = ' You can still copy the content to another location by pressing Esc.
Once you leave this page, it will disappear forever!'; + out.errorRedirectToHome = 'Press Esc to be redirected to your CryptDrive.'; out.loading = "Loading..."; out.error = "Error"; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index fab9dfcfd..11d20ce56 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -650,6 +650,12 @@ define([ Cryptpad.getMetadata(waitFor(function (err, m) { cpNfCfg.owners = [m.priv.edPublic]; })); + } else if (isNewFile && !cfg.useCreationScreen && window.location.hash) { + console.log("new file with hash in the address bar in an app without pcs and which requires owners"); + sframeChan.onReady(function () { + sframeChan.query("EV_LOADING_ERROR", "DELETED"); + }); + waitFor.abort(); } }).nThen(function () { Object.keys(rtConfig).forEach(function (k) { diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index c909c01f2..ab3c2389d 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -435,6 +435,15 @@ define([ Feedback.init(feedback); } catch (e) { Feedback.init(false); } + ctx.sframeChan.on('EV_LOADING_ERROR', function (err) { + if (err === 'DELETED') { + var msg = Messages.deletedError + '
' + Messages.errorRedirectToHome; + UI.errorLoadingScreen(msg, false, function () { + funcs.gotoURL('/drive/'); + }); + } + }); + ctx.sframeChan.on('EV_LOGOUT', function () { $(window).on('keyup', function (e) { if (e.keyCode === 27) { diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index 4c3046ad9..8142694ce 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -227,4 +227,7 @@ define({ // This is for sending data out of the iframe when we are in testing mode // The exact protocol is defined in common/test.js 'EV_TESTDATA': true, + + // Critical error outside the iframe during loading screen + 'EV_LOADING_ERROR': true, });