From 79bfa199f14faec26a61c423e6f3bac33ac4707c Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Tue, 31 Aug 2021 16:50:32 +0530 Subject: [PATCH 1/2] show specific err msg on password form --- src/languages/en.js | 2 ++ src/languages/es.js | 2 ++ src/pages/signin/PasswordForm.js | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 560e7d692f25..5f7f9efbf2bf 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -319,6 +319,8 @@ export default { }, passwordForm: { pleaseFillOutAllFields: 'Please fill out all fields', + pleaseFillPassword: 'Please enter your password', + pleaseFillTwoFactorAuth: 'Please enter your two factor code', enterYourTwoFactorAuthenticationCodeToContinue: 'Enter your two factor authentication code to continue', forgot: 'Forgot?', twoFactorCode: 'Two factor code', diff --git a/src/languages/es.js b/src/languages/es.js index e7c6bedbe49f..665f486bbf4c 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -319,6 +319,8 @@ export default { }, passwordForm: { pleaseFillOutAllFields: 'Por favor completa todos los campos', + pleaseFillPassword: 'Por favor, introduce tu contraseña', + pleaseFillTwoFactorAuth: 'Por favor, introduce tu código 2 Factores', enterYourTwoFactorAuthenticationCodeToContinue: 'Ingrese su código de autenticación de dos factores para continuar', forgot: '¿Te has olvidado?', twoFactorCode: 'Autenticación de 2 factores', diff --git a/src/pages/signin/PasswordForm.js b/src/pages/signin/PasswordForm.js index e0341fc4cf06..d4ba03f8e4a3 100755 --- a/src/pages/signin/PasswordForm.js +++ b/src/pages/signin/PasswordForm.js @@ -57,12 +57,19 @@ class PasswordForm extends React.Component { */ validateAndSubmitForm() { if (!this.state.password.trim() - || (this.props.account.requiresTwoFactorAuth && !this.state.twoFactorAuthCode.trim()) + && (this.props.account.requiresTwoFactorAuth && !this.state.twoFactorAuthCode.trim()) ) { this.setState({formError: 'passwordForm.pleaseFillOutAllFields'}); return; } - + if (!this.state.password.trim()) { + this.setState({formError: 'passwordForm.pleaseFillPassword'}); + return; + } + if (this.props.account.requiresTwoFactorAuth && !this.state.twoFactorAuthCode.trim()) { + this.setState({formError: 'passwordForm.pleaseFillTwoFactorAuth'}); + return; + } this.setState({ formError: null, }); From c26958731cfa5f76866d553237209aa05190445f Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Thu, 2 Sep 2021 19:21:09 +0530 Subject: [PATCH 2/2] make required changes (code-style) --- src/languages/es.js | 2 +- src/pages/signin/PasswordForm.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/languages/es.js b/src/languages/es.js index 665f486bbf4c..e11d188e0662 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -320,7 +320,7 @@ export default { passwordForm: { pleaseFillOutAllFields: 'Por favor completa todos los campos', pleaseFillPassword: 'Por favor, introduce tu contraseña', - pleaseFillTwoFactorAuth: 'Por favor, introduce tu código 2 Factores', + pleaseFillTwoFactorAuth: 'Por favor, introduce tu código 2 factores', enterYourTwoFactorAuthenticationCodeToContinue: 'Ingrese su código de autenticación de dos factores para continuar', forgot: '¿Te has olvidado?', twoFactorCode: 'Autenticación de 2 factores', diff --git a/src/pages/signin/PasswordForm.js b/src/pages/signin/PasswordForm.js index d4ba03f8e4a3..ff2b4cd69950 100755 --- a/src/pages/signin/PasswordForm.js +++ b/src/pages/signin/PasswordForm.js @@ -56,20 +56,21 @@ class PasswordForm extends React.Component { * Check that all the form fields are valid, then trigger the submit callback */ validateAndSubmitForm() { - if (!this.state.password.trim() - && (this.props.account.requiresTwoFactorAuth && !this.state.twoFactorAuthCode.trim()) - ) { + if (!this.state.password.trim() && this.props.account.requiresTwoFactorAuth && !this.state.twoFactorAuthCode.trim()) { this.setState({formError: 'passwordForm.pleaseFillOutAllFields'}); return; } + if (!this.state.password.trim()) { this.setState({formError: 'passwordForm.pleaseFillPassword'}); return; } + if (this.props.account.requiresTwoFactorAuth && !this.state.twoFactorAuthCode.trim()) { this.setState({formError: 'passwordForm.pleaseFillTwoFactorAuth'}); return; } + this.setState({ formError: null, });