Implement redirect-path for password method
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import { UnAuthenticatedError } from "@probo/relay";
|
||||
import { Navigate, useLocation, useRouteError } from "react-router";
|
||||
import { Navigate, useRouteError } from "react-router";
|
||||
|
||||
import { PageError } from "./PageError";
|
||||
|
||||
export function RootErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
const location = useLocation();
|
||||
|
||||
const search = new URLSearchParams([["redirect-path", window.location.href]]);
|
||||
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
return <Navigate to="/auth/login" state={{ from: location.pathname }} />;
|
||||
return <Navigate to={{ pathname: "/auth/login", search: "?" + search.toString() }} />;
|
||||
}
|
||||
|
||||
return <PageError error={error instanceof Error ? error : new Error("unknown error")} />;
|
||||
|
||||
Reference in New Issue
Block a user