Skip to content

Commit

Permalink
[frontend] Fix for user deletion on cache + prevent loop on error on …
Browse files Browse the repository at this point in the history
…Private Root (#9719)
  • Loading branch information
Kedae authored Jan 27, 2025
1 parent 762b8b2 commit e277e6c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
21 changes: 12 additions & 9 deletions opencti-platform/opencti-front/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom';
import React, { Suspense, lazy } from 'react';
import { HighLevelError, ErrorBoundary } from '@components/Error';
import { APP_BASE_PATH } from './relay/environment';
import { RedirectManager } from './components/RedirectManager';
import AuthBoundaryComponent from './private/components/AuthBoundary';
Expand All @@ -13,15 +14,17 @@ const App = () => (
<AuthBoundaryComponent>
<RedirectManager>
<Suspense fallback={<Loader />}>
<Routes>
<Route path="/dashboard/*" Component={PrivateRoot} />
<Route path="/public/*" Component={PublicRoot} />
{/* By default, redirect to dashboard */}
<Route
path="/*"
element={<Navigate to="/dashboard" replace={true} />}
/>
</Routes>
<ErrorBoundary display={HighLevelError}>
<Routes>
<Route path="/dashboard/*" Component={PrivateRoot} />
<Route path="/public/*" Component={PublicRoot} />
{/* By default, redirect to dashboard */}
<Route
path="/*"
element={<Navigate to="/dashboard" replace={true} />}
/>
</Routes>
</ErrorBoundary>
</Suspense>
</RedirectManager>
</AuthBoundaryComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import ErrorNotFound from '../../components/ErrorNotFound';
import { useFormatter } from '../../components/i18n';
import { commitMutation } from '../../relay/environment';

// Highest level of error catching, do not rely on any tierce (intl, theme, ...) pure fallback
export const HighLevelError = () => (
<Alert severity="error">An unknown error occurred. Please contact your administrator or OpenCTI maintainers</Alert>
);

// Really simple error display
export const SimpleError = () => {
const { t_i18n } = useFormatter();
Expand Down Expand Up @@ -78,7 +83,7 @@ class ErrorBoundaryComponent extends React.Component {
const types = map((e) => e.extensions.code, [...baseErrors, ...retroErrors]);
// Specific error catching
if (includes('COMPLEX_SEARCH_ERROR', types)) {
return <DedicatedWarning title={'Complex search'} description={'Your search have too much terms to be executed. Please limit the number of words or the complexity'}/>;
return <DedicatedWarning title={'Complex search'} description={'Your search have too much terms to be executed. Please limit the number of words or the complexity'} />;
}
// Access error must be forwarded
if (includes('FORBIDDEN_ACCESS', types) || includes('AUTH_REQUIRED', types)) {
Expand All @@ -91,6 +96,7 @@ class ErrorBoundaryComponent extends React.Component {
return this.props.children;
}
}

ErrorBoundaryComponent.propTypes = {
display: PropTypes.object,
children: PropTypes.node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const platformUsers = (context: AuthContext) => {
const reloadUsers = async () => {
const users = await listAllEntities(context, SYSTEM_USER, [ENTITY_TYPE_USER], { connectionFormat: false });
const allUserIds = users.map((user) => user.internal_id);
return Bluebird.map(allUserIds, (userId: string) => resolveUserById(context, userId), { concurrency: ES_MAX_CONCURRENCY });
return Bluebird.map(allUserIds, (userId: string) => resolveUserById(context, userId), { concurrency: ES_MAX_CONCURRENCY }).filter((u) => u != null);
};
return { values: null, fn: reloadUsers };
};
Expand Down

0 comments on commit e277e6c

Please sign in to comment.