From 350a2a46aa3b48d3223b6e5c14ddc5952d260dba Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 4 Mar 2026 12:43:18 -0800 Subject: fund ui --- src/routes/(app)/+layout.server.ts | 42 +++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'src/routes/(app)/+layout.server.ts') diff --git a/src/routes/(app)/+layout.server.ts b/src/routes/(app)/+layout.server.ts index f1cb4d24..f863e026 100644 --- a/src/routes/(app)/+layout.server.ts +++ b/src/routes/(app)/+layout.server.ts @@ -6,31 +6,35 @@ export async function load({ cookies, url, params }) { const { id, username } = params; const token = cookies.get("token"); - if (!token) redirect(307, "/login"); + const isSweep = pathname.match(/^\/fund\/[^/]+\/sweep/); + if (!token && !isSweep) redirect(307, "/login"); let user; - try { - user = await get("/me", auth(cookies)); - } catch (e) { - const { message } = e as Error; - if (message.startsWith("Rate")) { - await sleep(3000); - try { - user = await get("/me", auth(cookies)); - } catch (retryError) { - if (isInvalidTokenError(retryError) && pathname !== "/logout") { - redirect(307, "/logout"); + let hasArk = false; + if (token) { + try { + user = await get("/me", auth(cookies)); + } catch (e) { + const { message } = e as Error; + if (message.startsWith("Rate")) { + await sleep(3000); + try { + user = await get("/me", auth(cookies)); + } catch (retryError) { + if (isInvalidTokenError(retryError) && pathname !== "/logout") { + redirect(307, "/logout"); + } + throw retryError; } - throw retryError; + } else if (isInvalidTokenError(e) && pathname !== "/logout") { + redirect(307, "/logout"); + } else { + throw e; } - } else if (isInvalidTokenError(e) && pathname !== "/logout") { - redirect(307, "/logout"); - } else { - throw e; } - } - const hasArk = (await get("/accounts", auth(cookies))).some((a: any) => a.type === "ark"); + hasArk = (await get("/accounts", auth(cookies))).some((a: any) => a.type === "ark"); + } let subject; if (url.pathname.includes("/invoice") && id) { -- cgit v1.2.3