Page MenuHomePhabricator

D11705.id39804.diff
No OneTemporary

D11705.id39804.diff

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
@@ -129,7 +129,7 @@
return React.useCallback(
async (keyserverIDs?: $ReadOnlyArray<string>) => {
const identityPromise = (async () => {
- if (!usingCommServicesAccessToken) {
+ if (!usingCommServicesAccessToken || !commServicesAccessToken) {
return;
}
if (!identityClient) {
diff --git a/web/components/log-out-if-missing-csat-handler.react.js b/web/components/log-out-if-missing-csat-handler.react.js
new file mode 100644
--- /dev/null
+++ b/web/components/log-out-if-missing-csat-handler.react.js
@@ -0,0 +1,24 @@
+// @flow
+
+import * as React from 'react';
+
+import { logOutActionTypes, useLogOut } from 'lib/actions/user-actions.js';
+import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
+import { useSelector } from 'lib/utils/redux-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
+
+function LogOutIfMissingCSATHandler() {
+ const dispatchActionPromise = useDispatchActionPromise();
+ const callLogOut = useLogOut();
+
+ const hasAccessToken = useSelector(state => !!state.commServicesAccessToken);
+ const dataLoaded = useSelector(state => state.dataLoaded);
+
+ React.useEffect(() => {
+ if (!hasAccessToken && dataLoaded && usingCommServicesAccessToken) {
+ void dispatchActionPromise(logOutActionTypes, callLogOut());
+ }
+ }, [callLogOut, dataLoaded, dispatchActionPromise, hasAccessToken]);
+}
+
+export default LogOutIfMissingCSATHandler;
diff --git a/web/root.js b/web/root.js
--- a/web/root.js
+++ b/web/root.js
@@ -20,6 +20,7 @@
import { getWagmiConfig } from 'lib/utils/wagmi-utils.js';
import App from './app.react.js';
+import LogOutIfMissingCSATHandler from './components/log-out-if-missing-csat-handler.react.js';
import ErrorBoundary from './error-boundary.react.js';
import IdentityServiceContextProvider from './grpc/identity-service-context-provider.react.js';
import { defaultWebState } from './redux/default-state.js';
@@ -70,6 +71,7 @@
<Route path="*" component={App} />
</Router>
<KeyserverConnectionsHandler socketComponent={Socket} />
+ <LogOutIfMissingCSATHandler />
<PrekeysHandler />
<SQLiteDataHandler />
<IntegrityHandler />

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 3:37 AM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2536316
Default Alt Text
D11705.id39804.diff (2 KB)

Event Timeline