Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366640
D12221.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12221.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
@@ -115,9 +115,13 @@
return { currentUserInfo, preRequestUserState, keyserverIDs };
};
-function useLogOut(): (
- keyserverIDs?: $ReadOnlyArray<string>,
-) => Promise<LogOutResult> {
+type UseLogOutOptions = {
+ +logOutType?: 'legacy' | 'secondary_device',
+};
+
+function useLogOut(
+ options: UseLogOutOptions = {},
+): (keyserverIDs?: $ReadOnlyArray<string>) => Promise<LogOutResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
@@ -128,6 +132,7 @@
state => state.commServicesAccessToken,
);
+ const { logOutType } = options;
return React.useCallback(
async (keyserverIDs?: $ReadOnlyArray<string>) => {
const identityPromise = (async () => {
@@ -137,9 +142,13 @@
if (!identityClient) {
throw new Error('Identity service client is not initialized');
}
+ const callIdentityClientLogOut =
+ logOutType === 'secondary_device'
+ ? identityClient.logOutSecondaryDevice
+ : identityClient.logOut;
try {
await Promise.race([
- identityClient.logOut(),
+ callIdentityClientLogOut(),
(async () => {
await sleep(500);
throw new Error('identity log_out took more than 500ms');
@@ -167,6 +176,7 @@
callKeyserverLogOut,
commServicesAccessToken,
identityClient,
+ logOutType,
preRequestUserState,
],
);
@@ -208,6 +218,14 @@
}, [commServicesAccessToken, identityClient, preRequestUserState]);
}
+const secondaryDeviceLogOutOptions = Object.freeze({
+ logOutType: 'secondary_device',
+});
+
+function useSecondaryDeviceLogOut(): () => Promise<LogOutResult> {
+ return useLogOut(secondaryDeviceLogOutOptions);
+}
+
const claimUsernameActionTypes = Object.freeze({
started: 'CLAIM_USERNAME_STARTED',
success: 'CLAIM_USERNAME_SUCCESS',
@@ -1005,6 +1023,7 @@
legacyLogInActionTypes,
useLogOut,
useIdentityLogOut,
+ useSecondaryDeviceLogOut,
logOutActionTypes,
legacyKeyserverRegister,
legacyKeyserverRegisterActionTypes,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 12:01 PM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584587
Default Alt Text
D12221.diff (2 KB)
Attached To
Mode
D12221: [lib] Add hook for secondary device logout
Attached
Detach File
Event Timeline
Log In to Comment