Do not set continue when not needed + infer organizationId to assume after pw sign in
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { AssumptionRequiredError, UnAuthenticatedError } from "@probo/relay";
|
||||
import { Navigate, useRouteError } from "react-router";
|
||||
import { Navigate, useLocation, useRouteError } from "react-router";
|
||||
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
|
||||
@@ -8,17 +8,18 @@ import { PageError } from "./PageError";
|
||||
export function OrganizationErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
const organizationId = useOrganizationId();
|
||||
const location = useLocation();
|
||||
|
||||
const search = new URLSearchParams([
|
||||
["organization-id", organizationId],
|
||||
]);
|
||||
const search = new URLSearchParams();
|
||||
|
||||
if (window.location.href !== window.location.origin) {
|
||||
if (location.pathname !== "/" || location.search !== "") {
|
||||
search.set("continue", window.location.href);
|
||||
}
|
||||
|
||||
const queryString = search.toString();
|
||||
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
return <Navigate to={{ pathname: "/auth/login", search: "?" + search.toString() }} />;
|
||||
return <Navigate to={{ pathname: "/auth/login", search: queryString ? "?" + queryString : "" }} />;
|
||||
}
|
||||
|
||||
if (error instanceof AssumptionRequiredError) {
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
import { UnAuthenticatedError } from "@probo/relay";
|
||||
import { Navigate, useRouteError } from "react-router";
|
||||
import { Navigate, useLocation, useRouteError } from "react-router";
|
||||
|
||||
import { PageError } from "./PageError";
|
||||
|
||||
export function RootErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
const location = useLocation();
|
||||
|
||||
const search = new URLSearchParams();
|
||||
if (window.location.href !== window.location.origin) {
|
||||
|
||||
if (location.pathname !== "/" || location.search !== "") {
|
||||
search.set("continue", window.location.href);
|
||||
}
|
||||
|
||||
const queryString = search.toString();
|
||||
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
return (
|
||||
<Navigate to={{
|
||||
pathname: "/auth/login",
|
||||
search: search.toString() ? "?" + search.toString() : "",
|
||||
search: queryString ? "?" + queryString : "",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user