Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3521204
D14034.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
D14034.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
@@ -144,6 +144,7 @@
type UseLogOutOptions = {
+logOutType?: 'legacy' | 'primary_device' | 'secondary_device',
+skipIdentityLogOut?: boolean,
+ +handleUseNewFlowResponse?: () => void,
};
function useLogOut(
@@ -154,6 +155,7 @@
const preRequestUserState = usePreRequestUserState();
const callKeyserverLogOut = useKeyserverCall(keyserverLogOut);
+ const sendLogoutMessage = useSendLogoutMessageToPrimaryDevice(false);
const removeAllHolders = useClearAllHolders();
@@ -161,7 +163,7 @@
state => state.commServicesAccessToken,
);
- const { logOutType, skipIdentityLogOut } = options;
+ const { logOutType, skipIdentityLogOut, handleUseNewFlowResponse } = options;
return React.useCallback(
async (keyserverIDs?: $ReadOnlyArray<string>) => {
const holdersPromise = (async () => {
@@ -190,11 +192,30 @@
);
}
callIdentityClientLogOut = identityClient.logOutPrimaryDevice;
+ } else if (logOutType === 'secondary_device') {
+ callIdentityClientLogOut = identityClient.logOutSecondaryDevice;
} else {
- callIdentityClientLogOut =
- logOutType === 'secondary_device'
- ? identityClient.logOutSecondaryDevice
- : identityClient.logOut;
+ callIdentityClientLogOut = async () => {
+ try {
+ await identityClient.logOut();
+ } catch (e) {
+ const errorMessage = getMessageForException(e);
+ if (errorMessage !== 'use_new_flow') {
+ throw e;
+ }
+
+ // When use_new_flow is returned on legacy V1 login,
+ // we are sure that another device upgraded flows and has become
+ // primary, so this is now a secondary device which still uses
+ // old flow
+ try {
+ await sendLogoutMessage();
+ } catch (err) {
+ console.log('Failed to send logout message:', err);
+ }
+ handleUseNewFlowResponse?.();
+ }
+ };
}
try {
await Promise.race([
@@ -231,6 +252,8 @@
preRequestUserState,
removeAllHolders,
skipIdentityLogOut,
+ sendLogoutMessage,
+ handleUseNewFlowResponse,
],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 2:37 AM (18 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698003
Default Alt Text
D14034.diff (2 KB)
Attached To
Mode
D14034: [lib] Handle use_new_flow for Identity V1 logout
Attached
Detach File
Event Timeline
Log In to Comment