Page MenuHomePhabricator

D12221.id40675.diff
No OneTemporary

D12221.id40675.diff

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
@@ -113,9 +113,13 @@
return { currentUserInfo, preRequestUserState, keyserverIDs };
};
-function useLogOut(): (
- keyserverIDs?: $ReadOnlyArray<string>,
-) => Promise<LogOutResult> {
+type UseLogOutOptions = {
+ +logOutType?: 'identity' | 'secondary_device',
+};
+
+function useLogOut(
+ options: UseLogOutOptions = {},
+): (keyserverIDs?: $ReadOnlyArray<string>) => Promise<LogOutResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
@@ -126,18 +130,25 @@
state => state.commServicesAccessToken,
);
+ const { logOutType } = options;
+ const callIdentityClientLogOut = React.useMemo(() => {
+ if (!identityClient) {
+ throw new Error('Identity service client is not initialized');
+ }
+ return logOutType === 'secondary_device'
+ ? identityClient.logOutSecondaryDevice
+ : identityClient.logOut;
+ }, [logOutType, identityClient]);
+
return React.useCallback(
async (keyserverIDs?: $ReadOnlyArray<string>) => {
const identityPromise = (async () => {
if (!usingCommServicesAccessToken || !commServicesAccessToken) {
return;
}
- if (!identityClient) {
- throw new Error('Identity service client is not initialized');
- }
try {
await Promise.race([
- identityClient.logOut(),
+ callIdentityClientLogOut(),
(async () => {
await sleep(500);
throw new Error('identity log_out took more than 500ms');
@@ -164,7 +175,7 @@
[
callKeyserverLogOut,
commServicesAccessToken,
- identityClient,
+ callIdentityClientLogOut,
preRequestUserState,
],
);
@@ -206,6 +217,13 @@
}, [commServicesAccessToken, identityClient, preRequestUserState]);
}
+function useSecondaryDeviceLogOut(): () => Promise<LogOutResult> {
+ const logOut = useLogOut({
+ logOutType: 'secondary_device',
+ });
+ return logOut;
+}
+
const claimUsernameActionTypes = Object.freeze({
started: 'CLAIM_USERNAME_STARTED',
success: 'CLAIM_USERNAME_SUCCESS',
@@ -982,6 +1000,7 @@
legacyLogInActionTypes,
useLogOut,
useIdentityLogOut,
+ useSecondaryDeviceLogOut,
logOutActionTypes,
legacyKeyserverRegister,
legacyKeyserverRegisterActionTypes,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 10:58 AM (14 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570309
Default Alt Text
D12221.id40675.diff (2 KB)

Event Timeline