Page MenuHomePhabricator

D11670.diff
No OneTemporary

D11670.diff

diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js
--- a/native/data/sqlite-data-handler.js
+++ b/native/data/sqlite-data-handler.js
@@ -15,6 +15,7 @@
import { syncedMetadataStoreOpsHandlers } from 'lib/ops/synced-metadata-store-ops.js';
import { threadStoreOpsHandlers } from 'lib/ops/thread-store-ops.js';
import { userStoreOpsHandlers } from 'lib/ops/user-store-ops.js';
+import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
import { shouldClearData } from 'lib/shared/data-utils.js';
@@ -137,14 +138,24 @@
[],
);
+ const cookie = useSelector(cookieSelector(authoritativeKeyserverID));
+ const currentLoggedInToAuthKeyserverUserID =
+ cookie && cookie.startsWith('user=') ? currentLoggedInUserID : null;
const handleSensitiveData = React.useCallback(async () => {
try {
const sqliteStampedUserID = await commCoreModule.getSQLiteStampedUserID();
- if (shouldClearData(sqliteStampedUserID, currentLoggedInUserID)) {
+ if (
+ shouldClearData(
+ sqliteStampedUserID,
+ currentLoggedInToAuthKeyserverUserID,
+ )
+ ) {
await callClearSensitiveData('change in logged-in user credentials');
}
- if (currentLoggedInUserID) {
- await commCoreModule.stampSQLiteDBUserID(currentLoggedInUserID);
+ if (currentLoggedInToAuthKeyserverUserID) {
+ await commCoreModule.stampSQLiteDBUserID(
+ currentLoggedInToAuthKeyserverUserID,
+ );
}
} catch (e) {
if (isTaskCancelledError(e)) {
@@ -158,7 +169,7 @@
commCoreModule.terminate();
}
}
- }, [callClearSensitiveData, currentLoggedInUserID]);
+ }, [callClearSensitiveData, currentLoggedInToAuthKeyserverUserID]);
React.useEffect(() => {
if (!rehydrateConcluded) {
diff --git a/web/shared-worker/sqlite-data-handler.js b/web/shared-worker/sqlite-data-handler.js
--- a/web/shared-worker/sqlite-data-handler.js
+++ b/web/shared-worker/sqlite-data-handler.js
@@ -2,11 +2,13 @@
import * as React from 'react';
+import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
import { shouldClearData } from 'lib/shared/data-utils.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { getCommSharedWorker } from './shared-worker-provider.js';
+import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import { useSelector } from '../redux/redux-utils.js';
import { workerRequestMessageTypes } from '../types/worker-types.js';
@@ -15,9 +17,13 @@
const rehydrateConcluded = useSelector(
state => !!(state._persist && state._persist.rehydrated),
);
+
const currentLoggedInUserID = useSelector(state =>
state.currentUserInfo?.anonymous ? undefined : state.currentUserInfo?.id,
);
+ const cookie = useSelector(cookieSelector(authoritativeKeyserverID));
+ const currentLoggedInToAuthKeyserverUserID =
+ cookie && cookie.startsWith('user=') ? currentLoggedInUserID : null;
const handleSensitiveData = React.useCallback(async () => {
const sharedWorker = await getCommSharedWorker();
@@ -39,7 +45,7 @@
if (
errorGettingUserID ||
- shouldClearData(currentDBUserID, currentLoggedInUserID)
+ shouldClearData(currentDBUserID, currentLoggedInToAuthKeyserverUserID)
) {
try {
await sharedWorker.init({ clearDatabase: true });
@@ -54,11 +60,14 @@
}
}
- if (currentLoggedInUserID && currentLoggedInUserID !== currentDBUserID) {
+ if (
+ currentLoggedInToAuthKeyserverUserID &&
+ currentLoggedInToAuthKeyserverUserID !== currentDBUserID
+ ) {
try {
await sharedWorker.schedule({
type: workerRequestMessageTypes.STAMP_SQLITE_DB_USER_ID,
- userID: currentLoggedInUserID,
+ userID: currentLoggedInToAuthKeyserverUserID,
});
} catch (error) {
console.error(
@@ -68,7 +77,7 @@
);
}
}
- }, [currentLoggedInUserID]);
+ }, [currentLoggedInToAuthKeyserverUserID]);
React.useEffect(() => {
void (async () => {

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 8:55 PM (19 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577295
Default Alt Text
D11670.diff (4 KB)

Event Timeline