From 207d46eefd5bb276e9ec0fc1fd784cb3745bb47b Mon Sep 17 00:00:00 2001 From: Arda Samadi Date: Tue, 16 Jun 2026 15:00:53 +0330 Subject: [PATCH] Profile hard-guard: redirect /profile to /login when logged out The account sub-pages were already protected via validateTokens; add a loader on the profile index so the hub itself bounces to /login when unauthenticated. --- app/routes/profile._index.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/routes/profile._index.tsx b/app/routes/profile._index.tsx index 6889723..59f12ce 100644 --- a/app/routes/profile._index.tsx +++ b/app/routes/profile._index.tsx @@ -1,4 +1,5 @@ -import { MetaFunction } from "@remix-run/node"; +import { MetaFunction, redirect, type LoaderFunctionArgs } from "@remix-run/node"; +import { sessionStorage } from "~/sessions.server"; import { BookmarkMinus, ChevronLeft, @@ -33,6 +34,19 @@ interface MenuItemType { hasBorder?: boolean; image: React.ReactNode; } +// Guard: the account hub requires login (sub-pages are already protected via +// validateTokens; this covers the /profile index itself). +export async function loader({ request }: LoaderFunctionArgs) { + const session = await sessionStorage.getSession( + request.headers.get("cookie") + ); + const user = session.get("user"); + if (!user?.access_token) { + throw redirect("/login"); + } + return null; +} + export default function Profile() { const { user, theme: initialTheme } = useRootData(); const [storeModalOpen, setStoreModalOpen] = useState(false);