diff --git a/web/src/routes/admin/+layout.server.ts b/web/src/routes/admin/+layout.server.ts index 85520c3..0ac9079 100644 --- a/web/src/routes/admin/+layout.server.ts +++ b/web/src/routes/admin/+layout.server.ts @@ -11,10 +11,17 @@ export const load: LayoutServerLoad = async ({ request, url }) => { const sessionUser = request.headers.get("x-session-user"); if (!sessionUser) { - // Not authenticated - redirect to login with next parameter + const targetPath = url.pathname + url.search; + + // If redirecting to /admin (the default), omit the next parameter + if (targetPath === "/admin") { + throw redirect(302, "/admin/login"); + } + + // For other paths, include next parameter throw redirect( 302, - `/admin/login?next=${encodeURIComponent(url.pathname + url.search)}` + `/admin/login?next=${encodeURIComponent(targetPath)}` ); } diff --git a/web/src/routes/admin/settings/+page.svelte b/web/src/routes/admin/settings/[[tab]]/+page.svelte similarity index 93% rename from web/src/routes/admin/settings/+page.svelte rename to web/src/routes/admin/settings/[[tab]]/+page.svelte index c82b92e..3bcc3e2 100644 --- a/web/src/routes/admin/settings/+page.svelte +++ b/web/src/routes/admin/settings/[[tab]]/+page.svelte @@ -1,4 +1,6 @@ @@ -117,7 +129,7 @@ ? "border-indigo-500 text-zinc-50" : "border-transparent text-zinc-400 hover:text-zinc-300 hover:border-zinc-700" )} - onclick={() => (activeTab = "identity")} + onclick={() => navigateToTab("identity")} > Identity @@ -129,7 +141,7 @@ ? "border-indigo-500 text-zinc-50" : "border-transparent text-zinc-400 hover:text-zinc-300 hover:border-zinc-700" )} - onclick={() => (activeTab = "social")} + onclick={() => navigateToTab("social")} > Social Links @@ -141,7 +153,7 @@ ? "border-indigo-500 text-zinc-50" : "border-transparent text-zinc-400 hover:text-zinc-300 hover:border-zinc-700" )} - onclick={() => (activeTab = "admin")} + onclick={() => navigateToTab("admin")} > Admin Preferences