Skip to content

Commit

Permalink
[frontend] Fix additional query params lead to error display (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomuDeuxfois authored Mar 11, 2024
1 parent ca535ad commit f712234
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions openbas-front/src/public/components/login/LoginError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ import { useLocation } from 'react-router-dom';
import Message from '../../../components/Message';
import { MESSAGING$ } from '../../../utils/Environment';

const ERROR_KEY = 'error=';

const LoginError: FunctionComponent = () => {
const { search } = useLocation();
const error = search.substring(search.indexOf('error=') + 'error='.length);
if (error) {
MESSAGING$.notifyError(decodeURIComponent(error));
}

const params: string[] = search.split('&');
let error = '';
params.forEach((param) => {
if (param.includes(ERROR_KEY)) {
error = param.substring(param.indexOf(ERROR_KEY) + ERROR_KEY.length);
}
if (error) {
MESSAGING$.notifyError(decodeURIComponent(error));
}
});
return <Message sticky={false} />;
};

Expand Down

0 comments on commit f712234

Please sign in to comment.