Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2901497
D12639.id42006.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
D12639.id42006.diff
View Options
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -137,6 +137,7 @@
type UseLogOutOptions = {
+logOutType?: 'legacy' | 'primary_device' | 'secondary_device',
+ +skipIdentityLogOut?: boolean,
};
function useLogOut(
@@ -152,11 +153,15 @@
state => state.commServicesAccessToken,
);
- const { logOutType } = options;
+ const { logOutType, skipIdentityLogOut } = options;
return React.useCallback(
async (keyserverIDs?: $ReadOnlyArray<string>) => {
const identityPromise = (async () => {
- if (!usingCommServicesAccessToken || !commServicesAccessToken) {
+ if (
+ skipIdentityLogOut ||
+ !usingCommServicesAccessToken ||
+ !commServicesAccessToken
+ ) {
return;
}
if (!identityClient) {
@@ -209,6 +214,7 @@
identityClient,
logOutType,
preRequestUserState,
+ skipIdentityLogOut,
],
);
}
diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
--- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js
+++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
@@ -4,6 +4,7 @@
import _isEqual from 'lodash/fp/isEqual.js';
import * as React from 'react';
+import { logOutActionTypes, useLogOut } from '../actions/user-actions.js';
import {
useBroadcastDeviceListUpdates,
useGetAndUpdateDeviceListsForUsers,
@@ -33,8 +34,13 @@
import { getMessageForException } from '../utils/errors.js';
import { hasHigherDeviceID, olmSessionErrors } from '../utils/olm-utils.js';
import { getClientMessageIDFromTunnelbrokerMessageID } from '../utils/peer-to-peer-communication-utils.js';
+import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
+// When logout is requested by primary device, logging out of Identity Service
+// is already handled by the primary device
+const primaryRequestLogoutOptions = Object.freeze({ skipIdentityLogOut: true });
+
// handles `peerToPeerMessageTypes.ENCRYPTED_MESSAGE`
function useHandleOlmMessageToDevice() {
const identityContext = React.useContext(IdentityClientContext);
@@ -44,6 +50,9 @@
const broadcastDeviceListUpdates = useBroadcastDeviceListUpdates();
const allPeerDevices = useSelector(getAllPeerDevices);
+ const dispatchActionPromise = useDispatchActionPromise();
+ const primaryDeviceRequestedLogOut = useLogOut(primaryRequestLogoutOptions);
+
return React.useCallback(
async (decryptedMessageContent: string, senderInfo: SenderInfo) => {
const parsedMessageToDevice = JSON.parse(decryptedMessageContent);
@@ -58,9 +67,9 @@
userActionMessage.type ===
userActionsP2PMessageTypes.LOG_OUT_PRIMARY_DEVICE
) {
- console.log(
- 'Received primary device logout message from',
- senderInfo.deviceID,
+ void dispatchActionPromise(
+ logOutActionTypes,
+ primaryDeviceRequestedLogOut(),
);
} else if (
userActionMessage.type ===
@@ -82,7 +91,13 @@
);
}
},
- [allPeerDevices, broadcastDeviceListUpdates, identityClient],
+ [
+ allPeerDevices,
+ broadcastDeviceListUpdates,
+ dispatchActionPromise,
+ identityClient,
+ primaryDeviceRequestedLogOut,
+ ],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 6, 12:52 PM (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2249584
Default Alt Text
D12639.id42006.diff (3 KB)
Attached To
Mode
D12639: [lib] Log out secondary devices upon receiving primary logout message
Attached
Detach File
Event Timeline
Log In to Comment