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"); }, };