diff --git a/dev/Remote/User/Fetch.js b/dev/Remote/User/Fetch.js index 05fd3f1b6..182f15a23 100644 --- a/dev/Remote/User/Fetch.js +++ b/dev/Remote/User/Fetch.js @@ -58,10 +58,10 @@ class RemoteUserFetch extends AbstractFetchRemote { * @param {string=} sAdditionalCode * @param {boolean=} bAdditionalCodeSignMe */ - login(fCallback, sEmail, sLogin, sPassword, bSignMe, sLanguage, sAdditionalCode, bAdditionalCodeSignMe) { + login(fCallback, sEmail, sPassword, bSignMe, sLanguage, sAdditionalCode, bAdditionalCodeSignMe) { this.defaultRequest(fCallback, 'Login', { Email: sEmail, - Login: sLogin, + Login: '', Password: sPassword, Language: sLanguage || '', AdditionalCode: sAdditionalCode || '', diff --git a/dev/View/Admin/Login.js b/dev/View/Admin/Login.js index 70cc17bb9..fd8af23b4 100644 --- a/dev/View/Admin/Login.js +++ b/dev/View/Admin/Login.js @@ -31,12 +31,7 @@ class LoginAdminView extends AbstractViewCenter { this.addSubscribables({ login: () => this.loginError(false), - - password: () => this.passwordError(false), - - loginError: v => this.formError(!!v), - - passwordError: v => this.formError(!!v) + password: () => this.passwordError(false) }); decorateKoCommands(this, { @@ -44,33 +39,33 @@ class LoginAdminView extends AbstractViewCenter { }); } - submitCommand() { - this.loginError(false); - this.passwordError(false); + submitCommand(self, event) { + const valid = event.target.form.reportValidity(), + name = this.login().trim(), + pass = this.password(); - this.loginError(!this.login().trim()); - this.passwordError(!this.password().trim()); + this.loginError(!name); + this.passwordError(!pass); + this.formError(!valid); - if (this.loginError() || this.passwordError()) { - return false; + if (valid) { + this.submitRequest(true); + + Remote.adminLogin( + iError => { + if (iError) { + this.submitRequest(false); + this.submitError(getNotification(iError)); + } else { + rl.route.reload(); + } + }, + name, + pass + ); } - this.submitRequest(true); - - Remote.adminLogin( - (iError) => { - this.submitRequest(false); - if (iError) { - this.submitError(getNotification(iError)); - } else { - rl.route.reload(); - } - }, - this.login(), - this.password() - ); - - return true; + return valid; } onShow() { @@ -78,7 +73,7 @@ class LoginAdminView extends AbstractViewCenter { } submitForm() { - this.submitCommand(); +// return false; } } diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index f9a3d4593..d0e0e6467 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -95,13 +95,8 @@ class LoginUserView extends AbstractViewCenter { password: () => this.passwordError(false), additionalCode: () => this.additionalCodeError(false), - additionalCodeError: bV => this.formError(!!bV), additionalCodeVisibility: () => this.additionalCodeError(false), - emailError: bV => this.formError(!!bV), - - passwordError: bV => this.formError(!!bV), - submitError: value => value || this.submitErrorAddidional(''), signMeType: iValue => this.signMe(LoginSignMeType.DefaultOn === iValue) @@ -116,72 +111,53 @@ class LoginUserView extends AbstractViewCenter { }); } - windowOpenFeatures(wh) { - return `left=200,top=100,width=${wh},height=${wh},menubar=no,status=no,resizable=yes,scrollbars=yes`; - } + submitCommand(self, event) { + let email = this.email().trim(), + valid = event.target.form.reportValidity() && email, + pass = this.password(), + totp = this.additionalCodeVisibility(), + code = totp ? this.additionalCode() : ''; - submitCommand() { - this.emailError(false); - this.passwordError(false); + this.emailError(!email); + this.passwordError(!pass); + this.formError(!valid); + this.additionalCodeError(totp && !code); - let error; - if (this.additionalCodeVisibility()) { - this.additionalCodeError(false); - if (!this.additionalCode().trim()) { - this.additionalCodeError(true); - error = '.inputAdditionalCode'; - } - } - if (!this.password().trim()) { - this.passwordError(true); - error = '#RainLoopPassword'; - } - if (!this.email().trim()) { - this.emailError(true); - error = '#RainLoopEmail'; - } - if (error) { - this.querySelector(error).focus(); - return false; - } + if (valid) { + this.submitRequest(true); - this.submitRequest(true); - - const fLoginRequest = (sLoginPassword) => { Remote.login( (iError, oData) => { - this.submitRequest(false); if (iError) { + this.submitRequest(false); if (Notification.InvalidInputArgument == iError) { iError = Notification.AuthError; } this.submitError(getNotification(iError, oData.ErrorMessage, Notification.UnknownNotification)); this.submitErrorAddidional((oData && oData.ErrorMessageAdditional) || ''); + } else if (oData.TwoFactorAuth) { + this.submitRequest(false); + this.additionalCode(''); + this.additionalCodeVisibility(true); + let input = this.querySelector('.inputAdditionalCode'); + input.required = true; + setTimeout(() => input.focus(), 100); } else { - if (oData.TwoFactorAuth) { - this.additionalCode(''); - this.additionalCodeVisibility(true); - setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100); - } else { - rl.route.reload(); - } + rl.route.reload(); } }, - this.email(), - '', - sLoginPassword, + email, + pass, !!this.signMe(), this.bSendLanguage ? this.language() : '', - this.additionalCodeVisibility() ? this.additionalCode() : '', - this.additionalCodeVisibility() ? !!this.additionalCodeSignMe() : false + code, + !!(totp && this.additionalCodeSignMe()) ); Local.set(ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-'); - }; + } - fLoginRequest(this.password()); - - return true; + return valid; } onShow() { @@ -234,7 +210,7 @@ class LoginUserView extends AbstractViewCenter { } submitForm() { - this.submitCommand(); +// return false; } selectLanguage() { diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminLogin.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminLogin.html index b50304912..301d427fc 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminLogin.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminLogin.html @@ -8,10 +8,9 @@
- 👤 @@ -20,9 +19,9 @@
- 🔑 @@ -30,13 +29,13 @@
-
-
- diff --git a/snappymail/v/0.0.0/app/templates/Views/User/Login.html b/snappymail/v/0.0.0/app/templates/Views/User/Login.html index c76a3ed20..b2707d124 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/Login.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/Login.html @@ -18,10 +18,9 @@
- @@ -31,8 +30,7 @@
- @@ -46,11 +44,12 @@
- - 🔑 + 🔑
-
+