diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index cf443fe5f..90c2647ac 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -221,6 +221,12 @@ define([ return typeof getUserHash() === "string"; }; + var hasSigningKeys = common.hasSigningKeys = function (proxy) { + return typeof(proxy) === 'object' && + typeof(proxy.edPrivate) === 'string' && + typeof(proxy.edPublic) === 'string'; + }; + common.isArray = $.isArray; /* diff --git a/www/common/fsStore.js b/www/common/fsStore.js index edab0e252..88e57346c 100644 --- a/www/common/fsStore.js +++ b/www/common/fsStore.js @@ -156,6 +156,17 @@ define([ proxy.uid = Cryptpad.createChannelId(); } + // if the user is logged in, but does not have signing keys... + if (Cryptpad.isLoggedIn() && !Cryptpad.hasSigningKeys(proxy)) { + // log out so that you don't go into an endless loop... + Cryptpad.logout(); + + // redirect them to log in, and come back when they're done. + sessionStorage.redirectTo = window.location.href; + window.location.href = '/login/'; + return; + } + proxy.on('change', [Cryptpad.displayNameKey], function (o, n, p) { if (typeof(n) !== "string") { return; } Cryptpad.changeDisplayName(n);