diff options
| author | Adam Soltys <[email protected]> | 2026-11-04 14:29:35 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-04 14:38:48 -0700 |
| commit | a5ff626228b35ef587f6b9493998184e3e8354fe (patch) | |
| tree | f15d2726fbd391bbd3c4a3a1ca2826ff6c6ac2bd /src/routes/(app)/settings/delete/+page.server.ts | |
| parent | 976473a781f1bcda7ba02fee9db122e163243e2b (diff) | |
| download | coinos-ui-master.tar.gz coinos-ui-master.zip | |
A Delete account entry on the security tab leads to /settings/delete,
which warns what's lost, asks for the username (and PIN when set) and
calls the server's POST /delete, then logs out. The page resets to the
(app) layout so its form isn't nested in the settings save form.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/routes/(app)/settings/delete/+page.server.ts')
| -rw-r--r-- | src/routes/(app)/settings/delete/+page.server.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/routes/(app)/settings/delete/+page.server.ts b/src/routes/(app)/settings/delete/+page.server.ts new file mode 100644 index 00000000..05f4f026 --- /dev/null +++ b/src/routes/(app)/settings/delete/+page.server.ts @@ -0,0 +1,26 @@ +import { auth, post } from "$lib/utils"; +import { fail, redirect } from "@sveltejs/kit"; + +export async function load({ parent, url }) { + const { user } = await parent(); + if (!user) redirect(307, `/login?redirect=${encodeURIComponent(url.pathname)}`); +} + +export const actions = { + default: async ({ cookies, request }) => { + const form = await request.formData(); + const confirm = String(form.get("confirm") || ""); + const pin = String(form.get("pin") || ""); + + try { + // The server wipes everything (lib/deluser), including disabling the + // account's bolt12 offers, and refuses while a real balance remains. + await post("/delete", { confirm, ...(pin ? { pin } : {}) }, auth(cookies)); + } catch (e) { + return fail(400, { error: e?.message || String(e), confirm }); + } + + // The account is gone; /logout clears the session cookies. + redirect(303, "/logout"); + }, +}; |
