Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3295416
D11022.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11022.diff
View Options
diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js
--- a/web/grpc/identity-service-client-wrapper.js
+++ b/web/grpc/identity-service-client-wrapper.js
@@ -2,6 +2,7 @@
import { Login } from '@commapp/opaque-ke-wasm';
+import { setAccessTokenActionType } from 'lib/actions/user-actions.js';
import identityServiceConfig from 'lib/facts/identity-service.js';
import {
type IdentityServiceAuthLayer,
@@ -14,6 +15,7 @@
identityDeviceTypes,
identityAuthResultValidator,
} from 'lib/types/identity-service-types.js';
+import { type Dispatch } from 'lib/types/redux-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -36,10 +38,12 @@
authClient: ?IdentityAuthClient.IdentityClientServicePromiseClient;
unauthClient: IdentityUnauthClient.IdentityClientServicePromiseClient;
getDeviceKeyUpload: () => Promise<IdentityDeviceKeyUpload>;
+ dispatch: Dispatch;
constructor(
authLayer: ?IdentityServiceAuthLayer,
getDeviceKeyUpload: () => Promise<IdentityDeviceKeyUpload>,
+ dispatch: Dispatch,
) {
if (authLayer) {
this.authClient =
@@ -47,6 +51,7 @@
}
this.unauthClient = IdentityServiceClientWrapper.createUnauthClient();
this.getDeviceKeyUpload = getDeviceKeyUpload;
+ this.dispatch = dispatch;
}
static determineSocketAddr(): string {
@@ -280,7 +285,17 @@
const accessToken = loginFinishResponse.getAccessToken();
const identityAuthResult = { accessToken, userID, username };
- return assertWithValidator(identityAuthResult, identityAuthResultValidator);
+ const validatedResult = assertWithValidator(
+ identityAuthResult,
+ identityAuthResultValidator,
+ );
+
+ this.dispatch({
+ type: setAccessTokenActionType,
+ payload: validatedResult.accessToken,
+ });
+
+ return validatedResult;
};
logInWalletUser: (
@@ -312,7 +327,17 @@
const accessToken = loginResponse.getAccessToken();
const identityAuthResult = { accessToken, userID, username: walletAddress };
- return assertWithValidator(identityAuthResult, identityAuthResultValidator);
+ const validatedResult = assertWithValidator(
+ identityAuthResult,
+ identityAuthResultValidator,
+ );
+
+ this.dispatch({
+ type: setAccessTokenActionType,
+ payload: validatedResult.accessToken,
+ });
+
+ return validatedResult;
};
generateNonce: () => Promise<string> = async () => {
diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js
--- a/web/grpc/identity-service-context-provider.react.js
+++ b/web/grpc/identity-service-context-provider.react.js
@@ -6,6 +6,7 @@
IdentityClientContext,
type AuthMetadata,
} from 'lib/shared/identity-client-context.js';
+import { useDispatch } from 'lib/utils/redux-utils.js';
import { IdentityServiceClientWrapper } from './identity-service-client-wrapper.js';
import { useGetDeviceKeyUpload } from '../account/account-hooks.js';
@@ -23,6 +24,7 @@
state => state.cryptoStore?.primaryIdentityKeys.ed25519,
);
const getDeviceKeyUpload = useGetDeviceKeyUpload();
+ const dispatch = useDispatch();
const client = React.useMemo(() => {
let authLayer = null;
@@ -33,8 +35,12 @@
commServicesAccessToken: accessToken,
};
}
- return new IdentityServiceClientWrapper(authLayer, getDeviceKeyUpload);
- }, [accessToken, deviceID, getDeviceKeyUpload, userID]);
+ return new IdentityServiceClientWrapper(
+ authLayer,
+ getDeviceKeyUpload,
+ dispatch,
+ );
+ }, [accessToken, deviceID, dispatch, getDeviceKeyUpload, userID]);
const getAuthMetadata = React.useCallback<() => Promise<AuthMetadata>>(
async () => ({
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 9:41 PM (20 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2531974
Default Alt Text
D11022.diff (3 KB)
Attached To
Mode
D11022: [web] dispatch setAccessTokenActionType after successful identity login on web
Attached
Detach File
Event Timeline
Log In to Comment