Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3379526
D11694.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11694.diff
View Options
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
@@ -39,7 +39,16 @@
import { useStaffCanSee } from '../utils/staff-utils.js';
async function clearSensitiveData() {
- await commCoreModule.clearSensitiveData();
+ try {
+ await commCoreModule.clearSensitiveData();
+ } catch (error) {
+ console.log(
+ `Error clearing SQLite database: ${
+ getMessageForException(error) ?? 'unknown'
+ }`,
+ );
+ throw error;
+ }
try {
await filesystemMediaCache.clearCache();
} catch {
@@ -139,11 +148,28 @@
const handleSensitiveData = React.useCallback(async () => {
try {
- const sqliteStampedUserID = await commCoreModule.getSQLiteStampedUserID();
- if (shouldClearData(sqliteStampedUserID, currentLoggedInUserID)) {
+ let sqliteStampedUserID,
+ errorGettingStampedUserID = false;
+ try {
+ sqliteStampedUserID = await commCoreModule.getSQLiteStampedUserID();
+ } catch (error) {
+ errorGettingStampedUserID = true;
+ console.log(
+ `Error getting SQLite stamped user ID: ${
+ getMessageForException(error) ?? 'unknown'
+ }`,
+ );
+ }
+ if (
+ errorGettingStampedUserID ||
+ shouldClearData(sqliteStampedUserID, currentLoggedInUserID)
+ ) {
await callClearSensitiveData('change in logged-in user credentials');
}
- if (currentLoggedInUserID) {
+ if (
+ currentLoggedInUserID &&
+ currentLoggedInUserID !== sqliteStampedUserID
+ ) {
await commCoreModule.stampSQLiteDBUserID(currentLoggedInUserID);
}
} catch (e) {
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
@@ -21,25 +21,25 @@
const handleSensitiveData = React.useCallback(async () => {
const sharedWorker = await getCommSharedWorker();
- let currentDBUserID,
- errorGettingUserID = false;
+ let sqliteStampedUserID,
+ errorGettingStampedUserID = false;
try {
const currentUserData = await sharedWorker.schedule({
type: workerRequestMessageTypes.GET_SQLITE_STAMPED_USER_ID,
});
- currentDBUserID = currentUserData?.userID;
+ sqliteStampedUserID = currentUserData?.userID;
} catch (error) {
- errorGettingUserID = true;
+ errorGettingStampedUserID = true;
console.error(
- `Error setting current user ID: ${
+ `Error getting SQLite stamped user ID: ${
getMessageForException(error) ?? 'unknown'
}`,
);
}
if (
- errorGettingUserID ||
- shouldClearData(currentDBUserID, currentLoggedInUserID)
+ errorGettingStampedUserID ||
+ shouldClearData(sqliteStampedUserID, currentLoggedInUserID)
) {
try {
await sharedWorker.init({ clearDatabase: true });
@@ -54,7 +54,10 @@
}
}
- if (currentLoggedInUserID && currentLoggedInUserID !== currentDBUserID) {
+ if (
+ currentLoggedInUserID &&
+ currentLoggedInUserID !== sqliteStampedUserID
+ ) {
try {
await sharedWorker.schedule({
type: workerRequestMessageTypes.STAMP_SQLITE_DB_USER_ID,
@@ -62,7 +65,7 @@
});
} catch (error) {
console.error(
- `Error setting current user ID: ${
+ `Error stamping SQLite database with user ID: ${
getMessageForException(error) ?? 'unknown'
}`,
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 4:45 PM (21 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594464
Default Alt Text
D11694.diff (3 KB)
Attached To
Mode
D11694: [native][web] Align logic in SQLiteDataHandlers across platforms
Attached
Detach File
Event Timeline
Log In to Comment