diff options
Diffstat (limited to 'src/routes/(app)/+layout.server.ts')
| -rw-r--r-- | src/routes/(app)/+layout.server.ts | 42 |
1 files changed, 23 insertions, 19 deletions
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) { |
