From 8eede40000f6a541188c95370073e76113d152d8 Mon Sep 17 00:00:00 2001 From: whoswhip Date: Fri, 27 Mar 2026 20:19:54 -0400 Subject: [PATCH] feat: guest param in user page shows as if the user isnt logged in, except for the settings tab --- .../src/routes/user/[username]/+page.server.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts b/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts index 7c2e530..e408660 100644 --- a/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts +++ b/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts @@ -39,9 +39,10 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent const { username } = params; const { options } = await parent(); const jwtUuid = decodeJwtUuid(token); + const asGuest = url.searchParams.get('guest') === '1'; const res = await fetch(`${apiUrl}/api/user/${username}`, { - headers: token ? { Authorization: `Bearer ${token}` } : undefined + headers: token && !asGuest ? { Authorization: `Bearer ${token}` } : undefined }); if (!res.ok) { @@ -70,14 +71,14 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent }; } - if (token && canModerate && (!reportsSubmitted || !isOwner)) { + if (token && !asGuest && canModerate && (!reportsSubmitted || !isOwner)) { const submittedRes = await fetch(`${apiUrl}/api/user/${user.uuid}/reports/submitted`, { headers: { Authorization: `Bearer ${token}` } }); if (submittedRes.ok) reportsSubmitted = await submittedRes.json(); } - if (token && !isOwner) { + if (token && !asGuest && !isOwner) { if (canModerate) { const r = await fetch(`${apiUrl}/api/user/${user.uuid}/reports`, { headers: { Authorization: `Bearer ${token}` }