Skip to content

Commit

Permalink
Merge pull request #4945 from thesahindia/thesahindia/ui-ux/passwordForm
Browse files Browse the repository at this point in the history
show specific err msg on password form
  • Loading branch information
puneetlath authored Sep 2, 2021
2 parents 3140b84 + c269587 commit 175a1f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 11 additions & 3 deletions src/pages/signin/PasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +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,
});
Expand Down

0 comments on commit 175a1f2

Please sign in to comment.