Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3504254
D10965.id36672.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D10965.id36672.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
@@ -114,14 +114,29 @@
function useLogOut(): (
keyserverIDs?: $ReadOnlyArray<string>,
-) => Promise<KeyserverLogOutResult> {
+) => Promise<LogOutResult> {
const preRequestUserState = useSelector(preRequestUserStateSelector);
const callKeyserverLogOut = useKeyserverCall(logOut);
+ const commServicesAccessToken = useSelector(
+ state => state.commServicesAccessToken,
+ );
+
return React.useCallback(
- (keyserverIDs?: $ReadOnlyArray<string>) =>
- callKeyserverLogOut({ preRequestUserState, keyserverIDs }),
- [callKeyserverLogOut, preRequestUserState],
+ async (keyserverIDs?: $ReadOnlyArray<string>) => {
+ const { keyserverIDs: _, ...result } = await callKeyserverLogOut({
+ preRequestUserState,
+ keyserverIDs,
+ });
+ return {
+ ...result,
+ preRequestUserState: {
+ ...result.preRequestUserState,
+ commServicesAccessToken,
+ },
+ };
+ },
+ [callKeyserverLogOut, commServicesAccessToken, preRequestUserState],
);
}
@@ -203,6 +218,10 @@
const preRequestUserState = useSelector(preRequestUserStateSelector);
const callKeyserverDeleteAccount = useKeyserverCall(deleteKeyserverAccount);
+ const commServicesAccessToken = useSelector(
+ state => state.commServicesAccessToken,
+ );
+
return React.useCallback(async () => {
const identityPromise = (async () => {
if (!usingCommServicesAccessToken) {
@@ -220,8 +239,19 @@
identityPromise,
]);
const { keyserverIDs: _, ...result } = keyserverResult;
- return result;
- }, [callKeyserverDeleteAccount, identityClient, preRequestUserState]);
+ return {
+ ...result,
+ preRequestUserState: {
+ ...result.preRequestUserState,
+ commServicesAccessToken,
+ },
+ };
+ }, [
+ callKeyserverDeleteAccount,
+ commServicesAccessToken,
+ identityClient,
+ preRequestUserState,
+ ]);
}
const keyserverRegisterActionTypes = Object.freeze({
diff --git a/lib/shared/session-utils.js b/lib/shared/session-utils.js
--- a/lib/shared/session-utils.js
+++ b/lib/shared/session-utils.js
@@ -20,7 +20,7 @@
function invalidSessionDowngrade(
currentReduxState: AppState,
actionCurrentUserInfo: ?CurrentUserInfo,
- preRequestUserState: ?PreRequestUserState,
+ preRequestUserState: ?(PreRequestUserState | IdentityCallPreRequestUserState),
keyserverID: string,
): boolean {
// If this action represents a session downgrade - oldState has a loggedIn
diff --git a/lib/types/account-types.js b/lib/types/account-types.js
--- a/lib/types/account-types.js
+++ b/lib/types/account-types.js
@@ -14,7 +14,10 @@
type MessageTruncationStatuses,
type GenericMessagesResult,
} from './message-types.js';
-import type { PreRequestUserState } from './session-types.js';
+import type {
+ PreRequestUserState,
+ IdentityCallPreRequestUserState,
+} from './session-types.js';
import {
type MixedRawThreadInfos,
type RawThreadInfos,
@@ -35,11 +38,12 @@
export type LogOutResult = {
+currentUserInfo: ?LoggedOutUserInfo,
- +preRequestUserState: PreRequestUserState,
+ +preRequestUserState: IdentityCallPreRequestUserState,
};
export type KeyserverLogOutResult = $ReadOnly<{
- ...LogOutResult,
+ +currentUserInfo: ?LoggedOutUserInfo,
+ +preRequestUserState: PreRequestUserState,
+keyserverIDs: $ReadOnlyArray<string>,
}>;
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -228,7 +228,7 @@
}
| {
+type: 'LOG_OUT_SUCCESS',
- +payload: KeyserverLogOutResult,
+ +payload: LogOutResult,
+loadingInfo: LoadingInfo,
}
| {
diff --git a/native/crash.react.js b/native/crash.react.js
--- a/native/crash.react.js
+++ b/native/crash.react.js
@@ -19,7 +19,7 @@
sendReport,
} from 'lib/actions/report-actions.js';
import { logOutActionTypes, useLogOut } from 'lib/actions/user-actions.js';
-import type { KeyserverLogOutResult } from 'lib/types/account-types.js';
+import type { LogOutResult } from 'lib/types/account-types.js';
import { type ErrorData, reportTypes } from 'lib/types/report-types.js';
import { actionLogger } from 'lib/utils/action-logger.js';
import {
@@ -52,7 +52,7 @@
// Redux dispatch functions
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
- +logOut: () => Promise<KeyserverLogOutResult>,
+ +logOut: () => Promise<LogOutResult>,
+crashReportingEnabled: boolean,
};
type State = {
diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js
--- a/native/profile/profile-screen.react.js
+++ b/native/profile/profile-screen.react.js
@@ -7,7 +7,7 @@
import { useStringForUser } from 'lib/hooks/ens-cache.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import { accountHasPassword } from 'lib/shared/account-utils.js';
-import type { KeyserverLogOutResult } from 'lib/types/account-types.js';
+import type { LogOutResult } from 'lib/types/account-types.js';
import { type CurrentUserInfo } from 'lib/types/user-types.js';
import {
useDispatchActionPromise,
@@ -152,7 +152,7 @@
+colors: Colors,
+styles: $ReadOnly<typeof unboundStyles>,
+dispatchActionPromise: DispatchActionPromise,
- +logOut: () => Promise<KeyserverLogOutResult>,
+ +logOut: () => Promise<LogOutResult>,
+staffCanSee: boolean,
+stringForUser: ?string,
+isAccountWithPassword: boolean,
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -23,6 +23,7 @@
import {
invalidSessionDowngrade,
invalidSessionRecovery,
+ identityInvalidSessionDowngrade,
} from 'lib/shared/session-utils.js';
import { isStaff } from 'lib/shared/staff-utils.js';
import type { Dispatch, BaseAction } from 'lib/types/redux-types.js';
@@ -30,6 +31,7 @@
import type { SetSessionPayload } from 'lib/types/session-types.js';
import { reduxLoggerMiddleware } from 'lib/utils/action-logger.js';
import { resetUserSpecificStateOnIdentityActions } from 'lib/utils/reducers-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
import {
@@ -159,13 +161,21 @@
action.type === logOutActionTypes.success ||
action.type === deleteAccountActionTypes.success
) {
+ const { currentUserInfo, preRequestUserState } = action.payload;
if (
- invalidSessionDowngrade(
- state,
- action.payload.currentUserInfo,
- action.payload.preRequestUserState,
- ashoatKeyserverID,
- )
+ (usingCommServicesAccessToken &&
+ identityInvalidSessionDowngrade(
+ state,
+ currentUserInfo,
+ preRequestUserState,
+ )) ||
+ (!usingCommServicesAccessToken &&
+ invalidSessionDowngrade(
+ state,
+ currentUserInfo,
+ preRequestUserState,
+ ashoatKeyserverID,
+ ))
) {
return {
...state,
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -22,7 +22,10 @@
import baseReducer from 'lib/reducers/master-reducer.js';
import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
-import { invalidSessionDowngrade } from 'lib/shared/session-utils.js';
+import {
+ invalidSessionDowngrade,
+ identityInvalidSessionDowngrade,
+} from 'lib/shared/session-utils.js';
import type { CryptoStore } from 'lib/types/crypto-types.js';
import type { DraftStore } from 'lib/types/draft-types.js';
import type { EnabledApps } from 'lib/types/enabled-apps.js';
@@ -45,6 +48,7 @@
import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js';
import type { NotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import { resetUserSpecificStateOnIdentityActions } from 'lib/utils/reducers-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
import {
@@ -272,13 +276,21 @@
action.type === logOutActionTypes.success ||
action.type === deleteAccountActionTypes.success
) {
+ const { currentUserInfo, preRequestUserState } = action.payload;
if (
- invalidSessionDowngrade(
- oldState,
- action.payload.currentUserInfo,
- action.payload.preRequestUserState,
- ashoatKeyserverID,
- )
+ (usingCommServicesAccessToken &&
+ identityInvalidSessionDowngrade(
+ oldState,
+ currentUserInfo,
+ preRequestUserState,
+ )) ||
+ (!usingCommServicesAccessToken &&
+ invalidSessionDowngrade(
+ state,
+ currentUserInfo,
+ preRequestUserState,
+ ashoatKeyserverID,
+ ))
) {
return {
...oldState,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 8:05 AM (19 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687041
Default Alt Text
D10965.id36672.diff (9 KB)
Attached To
Mode
D10965: [lib][web][native] Handle invalidSessionDowngrade for identity actions
Attached
Detach File
Event Timeline
Log In to Comment