diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -227,7 +227,7 @@ } const userRow = userResult[0]; if (!userRow.hash || !bcrypt.compareSync(request.password, userRow.hash)) { - throw new ServerError('invalid_credentials'); + throw new ServerError('invalid_parameters'); } const id = userRow.id.toString(); diff --git a/native/account/log-in-panel.react.js b/native/account/log-in-panel.react.js --- a/native/account/log-in-panel.react.js +++ b/native/account/log-in-panel.react.js @@ -237,16 +237,6 @@ ); }; - onUsernameAlertAcknowledged: () => void = () => { - this.props.setActiveAlert(false); - this.props.logInState.setState( - { - usernameInputText: '', - }, - this.focusUsernameInput, - ); - }; - async logInAction(extraInfo: LogInExtraInfo): Promise { try { const result = await this.props.logIn({ @@ -264,16 +254,9 @@ } catch (e) { if (e.message === 'invalid_parameters') { Alert.alert( - 'Invalid username', - 'User doesn’t exist', - [{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }], - { cancelable: false }, - ); - } else if (e.message === 'invalid_credentials') { - Alert.alert( - 'Incorrect password', - 'The password you entered is incorrect', - [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }], + 'Incorrect username or password', + '', + [{ text: 'OK', onPress: this.onUnsuccessfulLoginAlertAckowledged }], { cancelable: false }, ); } else if (e.message === 'client_version_unsupported') { @@ -300,6 +283,27 @@ } } + onUnsuccessfulLoginAlertAckowledged: () => void = () => { + this.props.setActiveAlert(false); + this.props.logInState.setState( + { + usernameInputText: '', + }, + this.focusUsernameInput, + ); + }; + + onUsernameAlertAcknowledged: () => void = () => { + this.props.setActiveAlert(false); + this.props.logInState.setState( + { + usernameInputText: '', + passwordInputText: '', + }, + this.focusUsernameInput, + ); + }; + onPasswordAlertAcknowledged: () => void = () => { this.props.setActiveAlert(false); this.props.logInState.setState( diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js --- a/web/account/log-in-form.react.js +++ b/web/account/log-in-form.react.js @@ -40,7 +40,6 @@ const [errorMessage, setErrorMessage] = React.useState(''); const usernameInputRef = React.useRef(); - const passwordInputRef = React.useRef(); React.useEffect(() => { usernameInputRef.current?.focus(); @@ -70,16 +69,13 @@ } catch (e) { if (e.message === 'invalid_parameters') { setUsername(''); - setErrorMessage(`user doesn't exist`); - usernameInputRef.current?.focus(); - } else if (e.message === 'invalid_credentials') { setPassword(''); - setErrorMessage('wrong password'); - passwordInputRef.current?.focus(); + setErrorMessage(`Incorrect username or password`); + usernameInputRef.current?.focus(); } else { setUsername(''); setPassword(''); - setErrorMessage('unknown error'); + setErrorMessage('Unknown error'); usernameInputRef.current?.focus(); } throw e; @@ -149,7 +145,6 @@ placeholder="Password" value={password} onChange={onPasswordChange} - ref={passwordInputRef} disabled={inputDisabled} />