Skip to content

Commit

Permalink
Send user back to login when command channel connection is lost (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Apr 24, 2020
1 parent 35e8dbf commit 68de889
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
import { Alert, PageSection } from '@patternfly/react-core';
import { filter } from 'rxjs/operators';
import { DynamicImport } from '@app/DynamicImport';
import { accessibleRouteChangeHandler } from '@app/utils/utils';
import { NotFound } from '@app/NotFound/NotFound';
Expand Down Expand Up @@ -92,6 +93,13 @@ const AppRoutes = () => {
return () => sub.unsubscribe();
}, []);

React.useEffect(() => {
const sub = context.commandChannel.isReady().pipe(filter(v => !v)).subscribe(() =>
setAuthenticated(false)
);
return () => sub.unsubscribe();
}, []);

return (
<LastLocationProvider>
<Switch>
Expand Down

0 comments on commit 68de889

Please sign in to comment.