Catch assumption needed errors
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { AuthenticationRequiredError } from "@probo/relay";
|
||||
import { IconPageCross } from "@probo/ui";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useLocation, useRouteError } from "react-router";
|
||||
@@ -33,27 +32,6 @@ export function PageError({ resetErrorBoundary, error: propsError }: Props) {
|
||||
}
|
||||
}, [location, resetErrorBoundary]);
|
||||
|
||||
useEffect(() => {
|
||||
if (error instanceof AuthenticationRequiredError) {
|
||||
window.location.href = error.redirectUrl;
|
||||
}
|
||||
}, [error]);
|
||||
|
||||
if (error instanceof AuthenticationRequiredError) {
|
||||
return (
|
||||
<div className={classNames.wrapper}>
|
||||
<h1 className={classNames.title}>
|
||||
{__("Additional authentication required")}
|
||||
</h1>
|
||||
<p className={classNames.description}>
|
||||
{error.requiresSaml
|
||||
? __("Redirecting to SAML authentication...")
|
||||
: __("Redirecting to login...")}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!error || (error instanceof Error && error.message.includes("PAGE_NOT_FOUND"))) {
|
||||
return (
|
||||
<div className={classNames.wrapper}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Role } from "@probo/helpers";
|
||||
import { lazy } from "@probo/react-lazy";
|
||||
import {
|
||||
NotAssumingError,
|
||||
UnAuthenticatedError,
|
||||
} from "@probo/relay";
|
||||
import { type AppRoute, routeFromAppRoute } from "@probo/routes";
|
||||
@@ -47,6 +48,11 @@ function ErrorBoundary() {
|
||||
return <Navigate to="/auth/login" />;
|
||||
}
|
||||
|
||||
if (error instanceof NotAssumingError) {
|
||||
// TODO redirect to right URL
|
||||
return <Navigate to="/" />;
|
||||
}
|
||||
|
||||
return <PageError error={error instanceof Error ? error : new Error("unknown error")} />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user