Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33316262
D11020.1768828085.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D11020.1768828085.diff
View Options
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
@@ -16,6 +16,8 @@
import {
identityGenerateNonceActionTypes,
useIdentityGenerateNonce,
+ identityLogInActionTypes,
+ useIdentityWalletLogIn,
} from 'lib/actions/user-actions.js';
import ConnectedWalletInfo from 'lib/components/connected-wallet-info.react.js';
import SWMansionIcon from 'lib/components/swmansion-icon.react.js';
@@ -28,7 +30,7 @@
} from 'lib/types/account-types.js';
import type { OLMIdentityKeys } from 'lib/types/crypto-types.js';
import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js';
-import { ServerError } from 'lib/utils/errors.js';
+import { getMessageForException, ServerError } 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';
@@ -78,6 +80,8 @@
const legacySiweAuthCall = useLegacyAshoatKeyserverCall(siweAuth);
const logInExtraInfo = useSelector(logInExtraInfoSelector);
+ const identityWalletLogIn = useIdentityWalletLogIn();
+
const [siweNonce, setSIWENonce] = React.useState<?string>(null);
const siweNonceShouldBeFetched =
@@ -159,6 +163,29 @@
[callLegacySIWEAuthEndpoint, dispatchActionPromise, logInExtraInfo],
);
+ const attemptIdentityWalletLogIn = React.useCallback(
+ (walletAddress: string, siweMessage: string, siweSignature: string) => {
+ return dispatchActionPromise(
+ identityLogInActionTypes,
+ (async () => {
+ try {
+ return await identityWalletLogIn(
+ walletAddress,
+ siweMessage,
+ siweSignature,
+ );
+ } catch (e) {
+ if (getMessageForException(e) === 'user not found') {
+ setError('account_does_not_exist');
+ }
+ throw e;
+ }
+ })(),
+ );
+ },
+ [dispatchActionPromise, identityWalletLogIn],
+ );
+
const dispatch = useDispatch();
const onSignInButtonClick = React.useCallback(async () => {
invariant(signer, 'signer must be present during SIWE attempt');
@@ -172,16 +199,21 @@
);
const message = createSIWEMessage(address, statement, siweNonce);
const signature = await signer.signMessage({ message });
- await attemptLegacySIWEAuth(message, signature);
- dispatch({
- type: setDataLoadedActionType,
- payload: {
- dataLoaded: true,
- },
- });
+ if (usingCommServicesAccessToken) {
+ await attemptIdentityWalletLogIn(address, message, signature);
+ } else {
+ await attemptLegacySIWEAuth(message, signature);
+ dispatch({
+ type: setDataLoadedActionType,
+ payload: {
+ dataLoaded: true,
+ },
+ });
+ }
}, [
address,
attemptLegacySIWEAuth,
+ attemptIdentityWalletLogIn,
primaryIdentityPublicKeys,
signer,
siweNonce,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 1:08 PM (20 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5956518
Default Alt Text
D11020.1768828085.diff (3 KB)
Attached To
Mode
D11020: [web] use identity wallet login in siwe-login-form
Attached
Detach File
Event Timeline
Log In to Comment