Page MenuHomePhabricator

D12088.id40331.diff
No OneTemporary

D12088.id40331.diff

diff --git a/web/account/siwe-login-form.react.js b/web/account/siwe-login-form.react.js
--- a/web/account/siwe-login-form.react.js
+++ b/web/account/siwe-login-form.react.js
@@ -29,7 +29,7 @@
LegacyLogInExtraInfo,
} from 'lib/types/account-types.js';
import { SIWEMessageTypes } from 'lib/types/siwe-types.js';
-import { getMessageForException, ServerError } from 'lib/utils/errors.js';
+import { getMessageForException } from 'lib/utils/errors.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -46,8 +46,9 @@
import { olmAPI } from '../crypto/olm-api.js';
import LoadingIndicator from '../loading-indicator.react.js';
import { useSelector } from '../redux/redux-utils.js';
+import { getVersionUnsupportedError } from '../utils/version-utils.js';
-type SIWELogInError = 'account_does_not_exist';
+type SIWELogInError = 'account_does_not_exist' | 'client_version_unsupported';
type SIWELoginFormProps = {
+cancelSIWEAuthFlow: () => void,
@@ -137,11 +138,11 @@
...extraInfo,
});
} catch (e) {
- if (
- e instanceof ServerError &&
- e.message === 'account_does_not_exist'
- ) {
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'account_does_not_exist') {
setError('account_does_not_exist');
+ } else if (messageForException === 'client_version_unsupported') {
+ setError('client_version_unsupported');
}
throw e;
}
@@ -172,8 +173,14 @@
try {
return await walletLogIn(walletAddress, siweMessage, siweSignature);
} catch (e) {
- if (getMessageForException(e) === 'user not found') {
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'user not found') {
setError('account_does_not_exist');
+ } else if (
+ messageForException === 'client_version_unsupported' ||
+ messageForException === 'Unsupported version'
+ ) {
+ setError('client_version_unsupported');
}
throw e;
}
@@ -271,6 +278,8 @@
</p>
</>
);
+ } else if (error === 'client_version_unsupported') {
+ errorText = <p className={css.redText}>{getVersionUnsupportedError()}</p>;
}
return (
diff --git a/web/account/traditional-login-form.react.js b/web/account/traditional-login-form.react.js
--- a/web/account/traditional-login-form.react.js
+++ b/web/account/traditional-login-form.react.js
@@ -32,6 +32,7 @@
import LoadingIndicator from '../loading-indicator.react.js';
import Input from '../modals/input.react.js';
import { useSelector } from '../redux/redux-utils.js';
+import { getShortVersionUnsupportedError } from '../utils/version-utils.js';
const loadingStatusSelector = createLoadingStatusSelector(
legacyLogInActionTypes,
@@ -97,8 +98,11 @@
} catch (e) {
setUsername('');
setPassword('');
- if (getMessageForException(e) === 'invalid_credentials') {
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'invalid_credentials') {
setErrorMessage('incorrect username or password');
+ } else if (messageForException === 'client_version_unsupported') {
+ setErrorMessage(getShortVersionUnsupportedError());
} else {
setErrorMessage('unknown error');
}
@@ -128,6 +132,11 @@
messageForException === 'login failed'
) {
setErrorMessage('incorrect username or password');
+ } else if (
+ messageForException === 'client_version_unsupported' ||
+ messageForException === 'Unsupported version'
+ ) {
+ setErrorMessage(getShortVersionUnsupportedError());
} else {
setErrorMessage('unknown error');
}
diff --git a/web/utils/version-utils.js b/web/utils/version-utils.js
--- a/web/utils/version-utils.js
+++ b/web/utils/version-utils.js
@@ -15,4 +15,13 @@
);
}
-export { getVersionUnsupportedError };
+function getShortVersionUnsupportedError(): string {
+ const actionRequestMessage = isDesktopPlatform(
+ getConfig().platformDetails.platform,
+ )
+ ? 'please reload'
+ : 'please refresh';
+ return `client version unsupported. ${actionRequestMessage}`;
+}
+
+export { getVersionUnsupportedError, getShortVersionUnsupportedError };

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 7:31 PM (21 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2431232
Default Alt Text
D12088.id40331.diff (4 KB)

Event Timeline