refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -11,6 +11,7 @@ const Protected: FC<PropsWithChildren> = (props) => {
|
||||
const { ready, user } = useAuth();
|
||||
const location = useLocation();
|
||||
if (!ready) return <RouteSkeleton variant="shell" />;
|
||||
|
||||
return user
|
||||
? (
|
||||
<>{children}</>
|
||||
@@ -30,13 +31,17 @@ const Public: FC<PropsWithChildren> = (props) => {
|
||||
const location = useLocation();
|
||||
|
||||
if (!ready) return <RouteSkeleton variant="shell" />;
|
||||
const requested = (location.state as null | { returnTo?: string })?.returnTo;
|
||||
|
||||
const requested = (location.state as null
|
||||
| { returnTo?: string })?.returnTo;
|
||||
|
||||
const returnTo
|
||||
= typeof requested === "string"
|
||||
&& requested.startsWith("/")
|
||||
&& !requested.startsWith("//")
|
||||
? requested
|
||||
: "/accounts";
|
||||
|
||||
return user ? <Navigate replace to={returnTo} /> : <>{children}</>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user