diff --git a/customize.dist/main.js b/customize.dist/main.js index ac378e185..766977f0d 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -112,33 +112,46 @@ define([ }); $('button.login').click(function (e) { - loginReady(function () { - var uname = $uname.val(); - var passwd = $passwd.val(); - - Login.loginOrRegister(uname, passwd, false, function (err, result) { - if (!err) { - // successful validation and user already exists - // set user hash in localStorage and redirect to drive - localStorage.User_hash = result.userHash; - document.location.href = '/drive/'; - - return; - } - switch (err) { - case 'NO_SUCH_USER': - Cryptpad.alert('Invalid username or password. Try again, or sign up'); // XXX - break; - case 'INVAL_USER': - Cryptpad.alert('Username required'); // XXX - break; - case 'INVAL_PASS': - Cryptpad.alert('Password required'); // XXX - break; - default: // UNHANDLED ERROR - } + Cryptpad.addLoadingScreen(Messages.login_hashing); + // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password + window.setTimeout(function () { + loginReady(function () { + var uname = $uname.val(); + var passwd = $passwd.val(); + Login.loginOrRegister(uname, passwd, false, function (err, result) { + if (!err) { + // successful validation and user already exists + // set user hash in localStorage and redirect to drive + if (result.proxy && !result.proxy.login_name) { + result.proxy.login_name = result.userName; + } + Cryptpad.login(result.userHash, result.userName, function () { + document.location.href = '/drive/'; + }); + return; + } + switch (err) { + case 'NO_SUCH_USER': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_noSuchUser); + }); + break; + case 'INVAL_USER': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_invalUser); + }); + break; + case 'INVAL_PASS': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_invalPass); + }); + break; + default: // UNHANDLED ERROR + Cryptpad.errorLoadingScreen(Messages.login_unhandledError); + } + }); }); - }); + }, 0); }); /* End Log in UI */ diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 89237f351..2a14e9370 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -282,6 +282,15 @@ define(function () { out.login_accessDrive = 'Accédez à votre drive'; out.login_orNoLogin = 'ou'; + out.login_noSuchUser = "Nom d'utilisateur ou mot de passe invalide. Veuillez vous inscrire ou réessayer."; + out.login_invalUser = "Nom d'utilisateur requis"; + out.login_invalPass = 'Mot de passe requis'; + out.login_unhandledError = "Une erreur inattendue s'est produite :("; + + out.register_importRecent = "Importer l'historique (Recommendé)"; + out.register_acceptTerms = "J'accepte les conditions d'utilisation"; + out.register_rememberPassword = "Je vais me souvenir de mes identifiants"; + // index.html //out.main_p1 = 'CryptPad est l\'éditeur collaboratif en temps réel zero knowledge. Le chiffrement est effectué depuis votre navigateur, ce qui protège les données contre le serveur, le cloud, et la NSA. La clé de chiffrement est stockée dans l\'identifieur de fragment de l\'URL qui n\'est jamais envoyée au serveur mais est accessible depuis javascript, de sorte qu\'en partageant l\'URL, vous donnez l\'accès au pad à ceux qui souhaitent participer.'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 286b4e9b7..942364b49 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -283,8 +283,13 @@ define(function () { out.login_accessDrive = 'Access your drive'; out.login_orNoLogin = 'or'; + out.login_noSuchUser = 'Invalid username or password. Try again, or sign up'; + out.login_invalUser = 'Username required'; + out.login_invalPass = 'Password required'; + out.login_unhandledError = 'An unexpected error occured :('; + out.register_importRecent = "Import pad history (Recommended)"; - out.register_acceptTerms = "I accept the terms"; + out.register_acceptTerms = "I accept the terms of use"; out.register_rememberPassword = "I will remember my login name and password"; // index.html diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index de671f457..072a4ef16 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -746,7 +746,7 @@ define([ }; var LOADING = 'loading'; - common.addLoadingScreen = function () { + common.addLoadingScreen = function (loadingText) { if ($('#' + LOADING).length) { $('#' + LOADING).show(); return; @@ -756,7 +756,7 @@ define([ $container.append(''); var $spinner = $('
').text(Messages.loading); + var $text = $('
').text(loadingText || Messages.loading); $container.append($spinner).append($text); $loading.append($container); $('body').append($loading); diff --git a/www/login/main.js b/www/login/main.js index 26f673cf2..a6273b469 100644 --- a/www/login/main.js +++ b/www/login/main.js @@ -12,6 +12,7 @@ define([ $(function () { var $main = $('#mainBlock'); + var Messages = Cryptpad.Messages; // Language selector var $sel = $('#language-selector'); @@ -63,33 +64,46 @@ define([ }); $('button.login').click(function (e) { - loginReady(function () { - var uname = $uname.val(); - var passwd = $passwd.val(); - - Login.loginOrRegister(uname, passwd, false, function (err, result) { - if (!err) { - // successful validation and user already exists - // set user hash in localStorage and redirect to drive - localStorage.User_hash = result.userHash; - document.location.href = '/drive/'; - - return; - } - switch (err) { - case 'NO_SUCH_USER': - Cryptpad.alert('Invalid username or password. Try again, or sign up'); // XXX - break; - case 'INVAL_USER': - Cryptpad.alert('Username required'); // XXX - break; - case 'INVAL_PASS': - Cryptpad.alert('Password required'); // XXX - break; - default: // UNHANDLED ERROR - } + Cryptpad.addLoadingScreen(Messages.login_hashing); + // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password + window.setTimeout(function () { + loginReady(function () { + var uname = $uname.val(); + var passwd = $passwd.val(); + Login.loginOrRegister(uname, passwd, false, function (err, result) { + if (!err) { + // successful validation and user already exists + // set user hash in localStorage and redirect to drive + if (result.proxy && !result.proxy.login_name) { + result.proxy.login_name = result.userName; + } + Cryptpad.login(result.userHash, result.userName, function () { + document.location.href = '/drive/'; + }); + return; + } + switch (err) { + case 'NO_SUCH_USER': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_noSuchUser); + }); + break; + case 'INVAL_USER': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_invalUser); + }); + break; + case 'INVAL_PASS': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_invalPass); + }); + break; + default: // UNHANDLED ERROR + Cryptpad.errorLoadingScreen(Messages.login_unhandledError); + } + }); }); - }); + }, 0); }); }); });