diff options
| author | Adam Soltys <[email protected]> | 2024-09-24 15:57:04 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-24 15:57:04 -0700 |
| commit | 4373f870ad528811a9e0bb1a6749b01d5a7ec051 (patch) | |
| tree | fcc25342e1992d45e9ac5018fd2257c263376278 /src/routes/(app)/send | |
| parent | 8aeb0d6d818b823afec1ee7e5749971468842c9c (diff) | |
| download | coinos-ui-4373f870ad528811a9e0bb1a6749b01d5a7ec051.tar.gz coinos-ui-4373f870ad528811a9e0bb1a6749b01d5a7ec051.zip | |
stylin
Diffstat (limited to 'src/routes/(app)/send')
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/+layout.server.ts | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts index 6c22f5f1..a6edf8b0 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts +++ b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts @@ -1,12 +1,23 @@ import { auth, get } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, params }) { +export async function load({ cookies, params, parent }) { + let { user } = await parent(); let aid = cookies.get("aid"); let { address } = params; let { balance } = await get(`/account/${aid}`, auth(cookies)); - let invoice = await get(`/invoice/${address}`); - let recipient = await get(`/user/${invoice.uid}`); - if (invoice.aid === invoice.uid) redirect(307, `/send/${recipient.username}`); + + try { + let invoice = await get(`/invoice/${address}`); + + if (invoice) { + let recipient = await get(`/users/${invoice.uid}`); + if (recipient?.id !== user.id) + redirect(307, `/pay/${recipient.username}`); + } + } catch (e) { + // invoice not found + } + return { balance }; } |
