From fa2ad4e476107fdd8e215ff859370bef0188aad0 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 22 Oct 2019 13:06:21 +0200 Subject: [PATCH] Add /p/ to the hash when adding a password --- www/common/outer/async-store.js | 5 ++--- www/common/sframe-common-outer.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index eaa019384..cc94e9d25 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1531,8 +1531,7 @@ define([ Store.leavePad = function (clientId, data, cb) { var channel = channels[data.channel]; if (!channel || !channel.cpNf) { return void cb ({error: 'EINVAL'}); } - channel.cpNf.stop(); - delete channels[data.channel]; + Store.dropChannel(data.channel); cb(); }; Store.sendPadMsg = function (clientId, data, cb) { @@ -1850,7 +1849,7 @@ define([ // Clients management var driveEventClients = []; - var dropChannel = function (chanId) { + var dropChannel = Store.dropChannel = function (chanId) { try { store.messenger.leavePad(chanId); } catch (e) { console.error(e); } diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 84c08416a..431e274bb 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -174,7 +174,16 @@ define([ var parsed = Utils.Hash.parsePadUrl(window.location.href); var todo = function () { secret = Utils.secret = Utils.Hash.getSecrets(parsed.type, void 0, password); - Cryptpad.getShareHashes(secret, waitFor(function (err, h) { hashes = h; })); + Cryptpad.getShareHashes(secret, waitFor(function (err, h) { + hashes = h; + if (password && !parsed.hashData.password) { + var ohc = window.onhashchange; + window.onhashchange = function () {}; + window.location.hash = h.fileHash || h.editHash || h.viewHash || window.location.hash; + window.onhashchange = ohc; + ohc({reset: true}); + } + })); }; if (!parsed.hashData) { // No hash, no need to check for a password