Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/pages/signin/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class LoginForm extends React.Component {
render() {
const formErrorText = this.state.formError ? this.props.translate(this.state.formError) : '';
const serverErrorText = ErrorUtils.getLatestErrorMessage(this.props.account);
const hasError = !_.isEmpty(serverErrorText);
return (
<>
<View accessibilityLabel={this.props.translate('loginForm.loginForm')} style={[styles.mt3]}>
Expand All @@ -183,6 +184,7 @@ class LoginForm extends React.Component {
autoCorrect={false}
keyboardType={CONST.KEYBOARD_TYPE.EMAIL_ADDRESS}
errorText={formErrorText}
hasError={hasError}
/>
</View>
{!_.isEmpty(this.props.account.success) && (
Expand Down
12 changes: 10 additions & 2 deletions src/pages/signin/PasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ class PasswordForm extends React.Component {
}

render() {
const isTwoFactorAuthRequired = Boolean(this.props.account.requiresTwoFactorAuth);
const hasServerError = Boolean(this.props.account) && !_.isEmpty(this.props.account.errors);

// When the 2FA required flag is set, user has already passed/completed the password field
const passwordFieldHasError = !isTwoFactorAuthRequired && hasServerError;
const twoFactorFieldHasError = isTwoFactorAuthRequired && hasServerError;
return (
<>
<View style={[styles.mv3]}>
Expand All @@ -184,6 +190,7 @@ class PasswordForm extends React.Component {
onSubmitEditing={this.validateAndSubmitForm}
blurOnSubmit={false}
errorText={this.state.formError.password ? this.props.translate(this.state.formError.password) : ''}
hasError={passwordFieldHasError}
/>
<View style={[styles.changeExpensifyLoginLinkContainer]}>
<TouchableOpacity
Expand All @@ -197,7 +204,7 @@ class PasswordForm extends React.Component {
</View>
</View>

{this.props.account.requiresTwoFactorAuth && (
{isTwoFactorAuthRequired && (
<View style={[styles.mv3]}>
<TextInput
ref={el => this.input2FA = el}
Expand All @@ -211,11 +218,12 @@ class PasswordForm extends React.Component {
blurOnSubmit={false}
maxLength={CONST.TFA_CODE_LENGTH}
errorText={this.state.formError.twoFactorAuthCode ? this.props.translate(this.state.formError.twoFactorAuthCode) : ''}
hasError={twoFactorFieldHasError}
/>
</View>
)}

{Boolean(this.props.account) && !_.isEmpty(this.props.account.errors) && (
{hasServerError && (
<FormHelpMessage message={ErrorUtils.getLatestErrorMessage(this.props.account)} />
)}
<View>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class BaseValidateCodeForm extends React.Component {
}

render() {
const hasError = Boolean(this.props.account) && !_.isEmpty(this.props.account.errors);
return (
<>
Comment thread
suphero marked this conversation as resolved.
Outdated
{/* At this point, if we know the account requires 2FA we already successfully authenticated */}
Expand All @@ -206,6 +207,7 @@ class BaseValidateCodeForm extends React.Component {
blurOnSubmit={false}
maxLength={CONST.TFA_CODE_LENGTH}
errorText={this.state.formError.twoFactorAuthCode ? this.props.translate(this.state.formError.twoFactorAuthCode) : ''}
hasError={hasError}
/>
</View>
) : (
Expand All @@ -223,6 +225,7 @@ class BaseValidateCodeForm extends React.Component {
blurOnSubmit={false}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
errorText={this.state.formError.validateCode ? this.props.translate(this.state.formError.validateCode) : ''}
hasError={hasError}
autoFocus
/>
<View style={[styles.changeExpensifyLoginLinkContainer]}>
Expand All @@ -245,7 +248,7 @@ class BaseValidateCodeForm extends React.Component {
</View>
)}

{Boolean(this.props.account) && !_.isEmpty(this.props.account.errors) && (
{hasError && (
<FormHelpMessage message={ErrorUtils.getLatestErrorMessage(this.props.account)} />
)}
<View>
Expand Down