Page MenuHomePhabricator

D5368.id17573.diff
No OneTemporary

D5368.id17573.diff

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
@@ -4,6 +4,7 @@
import t from 'tcomb';
import bcrypt from 'twin-bcrypt';
+import { hasMinCodeVersion } from 'lib/shared/version-utils';
import type {
ResetPasswordRequest,
LogOutResponse,
@@ -227,7 +228,11 @@
}
const userRow = userResult[0];
if (!userRow.hash || !bcrypt.compareSync(request.password, userRow.hash)) {
- throw new ServerError('invalid_credentials');
+ if (hasMinCodeVersion(viewer.platformDetails, 99999)) {
+ throw new ServerError('invalid_parameters');
+ } else {
+ throw new ServerError('invalid_credentials');
+ }
}
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<LogInResult> {
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<string>('');
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}
/>
</div>

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 9:33 AM (17 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2699439
Default Alt Text
D5368.id17573.diff (4 KB)

Event Timeline