From f723585758e1d6bd9193db81af6615badfc25798 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 13 Feb 2017 10:42:17 +0100 Subject: [PATCH 1/4] add api to check whether the realtime has synced with the server --- www/common/cryptpad-common.js | 12 ++++++++++++ www/register/main.js | 16 ++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index fc7bee587..de671f457 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -44,6 +44,18 @@ define([ return; }; + var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) { + realtime.sync(); + var interval = 300; + var check = function () { + if (realtime.getAuthDoc() !== realtime.getUserDoc()) { + return window.setTimeout(check, interval); + } + cb(); + }; + window.setTimeout(check, interval); + }; + var getWebsocketURL = common.getWebsocketURL = function () { if (!Config.websocketPath) { return Config.websocketURL; } var path = Config.websocketPath; diff --git a/www/register/main.js b/www/register/main.js index 3ea0bf0ab..247a216fe 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -51,7 +51,7 @@ define([ } [ $uname, $passwd, $confirm] - .some(function ($el) { if (!$el.val()) { return ($el.focus(), true); } }); + .some(function ($el) { if (!$el.val()) { $el.focus(); return true; } }); // checkboxes var $checkImport = $('#import-recent'); @@ -60,18 +60,6 @@ define([ var $register = $('button#register'); - var proxyIsSynced = function (realtime, cb) { - realtime.sync(); - var interval = 300; - var check = function () { - if (realtime.getAuthDoc() !== realtime.getUserDoc()) { - return window.setTimeout(check, interval); - } - cb(); - }; - window.setTimeout(check, interval); - }; - $register.click(function () { var uname = $uname.val(); var passwd = $passwd.val(); @@ -108,7 +96,7 @@ define([ proxy.login_name = uname; - proxyIsSynced(result.realtime, function () { + Cryptpad.whenRealtimeSyncs(result.realtime, function () { document.location.href = '/drive/'; }); }); From 5614bea271520612cd4f215e719c9f58923639f2 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 13 Feb 2017 10:51:54 +0100 Subject: [PATCH 2/4] redirect users to login and register from toolbar --- www/common/toolbar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/toolbar.js b/www/common/toolbar.js index ab09497ae..a9a2435ae 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -465,10 +465,10 @@ define([ window.location.href = '/'; }); $userAdmin.find('a.login').click(function (e) { - window.open('/user'); + window.location.href = '/login/'; }); $userAdmin.find('a.register').click(function (e) { - window.open('/register/'); + window.location.href = '/register/'; }); if (config.userName && config.userName.setName && config.userName.lastName) { From fbcf4ccec4881d44b7cda1bea9e13bcc835840e9 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 13 Feb 2017 11:01:30 +0100 Subject: [PATCH 3/4] force usernames to be lowercase --- www/common/login.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/common/login.js b/www/common/login.js index bf3848c70..99678b1dd 100644 --- a/www/common/login.js +++ b/www/common/login.js @@ -70,6 +70,9 @@ define([ Exports.loginOrRegister = function (uname, passwd, isRegister, cb) { if (typeof(cb) !== 'function') { return; } + // Usernames are all lowercase. No going back on this one + uname = uname.toLowerCase(); + // validate inputs if (!Cred.isValidUsername(uname)) { return void cb('INVAL_USER'); } if (!Cred.isValidPassword(passwd)) { return void cb('INVAL_PASS'); } From 20083264b2c9c0521f89e11795e46e4cca02fcf5 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 13 Feb 2017 11:09:44 +0100 Subject: [PATCH 4/4] load fontawesome icons on register page --- www/register/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/www/register/index.html b/www/register/index.html index b11ed07f1..013d6ac10 100644 --- a/www/register/index.html +++ b/www/register/index.html @@ -4,6 +4,7 @@ Cryptpad: login +