From f29f430e7c2cb2a16878639901d9c4fc65064b82 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 19 Jun 2017 12:38:24 +0200 Subject: [PATCH 1/3] better handling of non-rpc messages --- www/common/rpc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/rpc.js b/www/common/rpc.js index 530a65483..02453a9e8 100644 --- a/www/common/rpc.js +++ b/www/common/rpc.js @@ -63,6 +63,7 @@ types of messages: // RPC responses are arrays. this message isn't meant for us. return; } + if (/FULL_HISTORY/.test(parsed[0])) { return; } var response = parsed.slice(2); @@ -98,7 +99,7 @@ types of messages: delete ctx.pending[txid]; return; } - console.error("received message for txid[%s] with no callback", txid); + console.error("received message [%s] for txid[%s] with no callback", msg, txid); }; var create = function (network, edPrivateKey, edPublicKey, cb) { From 06ca70d11ee09e3a6c4898c2dc00d44ae3b0f207 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 19 Jun 2017 14:05:40 +0200 Subject: [PATCH 2/3] lint compliance --- www/slide/slide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/slide/slide.js b/www/slide/slide.js index fd5277853..f0e47a272 100644 --- a/www/slide/slide.js +++ b/www/slide/slide.js @@ -144,7 +144,7 @@ define([ updateFontSize(); }; - Slide.update = function (content, init) { + Slide.update = function (content) { updateFontSize(); //if (!init) { return; } if (!content) { content = ''; } From 35e0de463b8fbbd5fa79dfdfcbd0c525fece0441 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 19 Jun 2017 14:18:10 +0200 Subject: [PATCH 3/3] disallow concurrent scrypt cycles --- www/register/main.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/www/register/main.js b/www/register/main.js index bdaca5197..f0b9a2e9c 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -63,6 +63,7 @@ define([ var $register = $('button#register'); + var registering = false; var logMeIn = function (result) { if (Test.testing) { Test.passed(); @@ -79,6 +80,7 @@ define([ Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.login(result.userHash, result.userName, function () { + registering = false; if (sessionStorage.redirectTo) { var h = sessionStorage.redirectTo; var parser = document.createElement('a'); @@ -95,6 +97,11 @@ define([ }; $register.click(function () { + if (registering) { + console.log("registration is already in progress"); + return; + } + var uname = $uname.val(); var passwd = $passwd.val(); var confirmPassword = $confirm.val(); @@ -115,6 +122,7 @@ define([ function (yes) { if (!yes) { return; } + registering = true; // setTimeout 100ms to remove the keyboard on mobile devices before the loading screen pops up window.setTimeout(function () { Cryptpad.addLoadingScreen(Messages.login_hashing); @@ -127,20 +135,27 @@ define([ switch (err) { case 'NO_SUCH_USER': Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_noSuchUser); + Cryptpad.alert(Messages.login_noSuchUser, function () { + registering = false; + }); }); break; case 'INVAL_USER': Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_invalUser); + Cryptpad.alert(Messages.login_invalUser, function () { + registering = false; + }); }); break; case 'INVAL_PASS': Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_invalPass); + Cryptpad.alert(Messages.login_invalPass, function () { + registering = false; + }); }); break; case 'ALREADY_REGISTERED': + // logMeIn should reset registering = false Cryptpad.removeLoadingScreen(function () { Cryptpad.confirm(Messages.register_alreadyRegistered, function (yes) { if (!yes) { return; } @@ -155,6 +170,7 @@ define([ }); break; default: // UNHANDLED ERROR + registering = false; Cryptpad.errorLoadingScreen(Messages.login_unhandledError); } return;