Skip to content

Commit

Permalink
[lib] Handle invalid CSAT in Identity Search context
Browse files Browse the repository at this point in the history
Summary:
Similiar to D13956 but for Identity Search

Depends on D14030

Test Plan: Repeated plan from D13956

Reviewers: kamil, will

Reviewed By: kamil

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D14031
  • Loading branch information
barthap committed Nov 29, 2024
1 parent 4ff096b commit e6ee808
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/identity-search/identity-search-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import invariant from 'invariant';
import * as React from 'react';
import uuid from 'uuid';

import { useInvalidCSATLogOut } from '../actions/user-actions.js';
import { identitySearchURL } from '../facts/identity-search.js';
import {
clientRequestVisualTimeout,
Expand Down Expand Up @@ -64,6 +65,7 @@ function IdentitySearchProvider(props: Props): React.Node {
const [connected, setConnected] = React.useState(false);
const listeners = React.useRef<Set<IdentitySearchSocketListener>>(new Set());
const getIdentitySearchAuthMessage = useGetIdentitySearchAuthMessage();
const invalidTokenLogOut = useInvalidCSATLogOut();
const [identitySearchAuthMessage, setIdentitySearchAuthMessage] =
React.useState<?IdentitySearchAuthMessage>(null);
const socket = React.useRef<?WebSocket>(null);
Expand Down Expand Up @@ -170,6 +172,10 @@ function IdentitySearchProvider(props: Props): React.Node {
'Success for already connected socket',
);
} else {
if (message.status.data?.includes('UnauthorizedDevice')) {
void invalidTokenLogOut();
return;
}
setConnected(false);
console.log(
'creating session with Identity Search error:',
Expand Down Expand Up @@ -207,6 +213,7 @@ function IdentitySearchProvider(props: Props): React.Node {
identitySearchAuthMessage,
resetHeartbeatTimeout,
stopHeartbeatTimeout,
invalidTokenLogOut,
]);

const sendPrefixQuery: (
Expand Down

0 comments on commit e6ee808

Please sign in to comment.