Page MenuHomePhabricator

D4730.diff
No OneTemporary

D4730.diff

diff --git a/native/data/sensitive-data-cleaner.react.js b/native/data/sensitive-data-cleaner.react.js
new file mode 100644
--- /dev/null
+++ b/native/data/sensitive-data-cleaner.react.js
@@ -0,0 +1,38 @@
+// @flow
+
+import * as React from 'react';
+import ExitApp from 'react-native-exit-app';
+
+import { useSelector } from '../redux/redux-utils';
+
+function SensitiveDataCleaner(): null {
+ const currentLoggedInUserID = useSelector(state =>
+ state.currentUserInfo?.anonymous ? null : state.currentUserInfo?.id,
+ );
+ React.useEffect(() => {
+ (async () => {
+ try {
+ const databaseCurrentUserInfoID = await global.CommCoreModule.getCurrentUserID();
+ if (
+ databaseCurrentUserInfoID &&
+ databaseCurrentUserInfoID !== currentLoggedInUserID
+ ) {
+ await global.CommCoreModule.clearSensitiveData();
+ }
+ if (currentLoggedInUserID) {
+ await global.CommCoreModule.setCurrentUserID(currentLoggedInUserID);
+ }
+ } catch (e) {
+ if (__DEV__) {
+ throw e;
+ } else {
+ console.log(e);
+ ExitApp.exitApp();
+ }
+ }
+ })();
+ }, [currentLoggedInUserID]);
+ return null;
+}
+
+export { SensitiveDataCleaner };
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -22,6 +22,7 @@
import PersistedStateGate from './components/persisted-state-gate';
import ConnectedStatusBar from './connected-status-bar.react';
import CoreDataProvider from './data/core-data-provider.react';
+import { SensitiveDataCleaner } from './data/sensitive-data-cleaner.react';
import { SQLiteContextProvider } from './data/sqlite-context-provider';
import ErrorBoundary from './error-boundary.react';
import InputStateContainer from './input/input-state-container.react';
@@ -222,6 +223,7 @@
<ConnectivityUpdater />
<ThemeHandler />
<OrientationHandler />
+ <SensitiveDataCleaner />
</>
);
let navigation;

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 1:12 AM (20 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587199
Default Alt Text
D4730.diff (1 KB)

Event Timeline