diff options
| author | Adam Soltys <[email protected]> | 2026-08-03 13:04:37 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-03 13:04:37 -0700 |
| commit | efa4a719786633ba905798cdc46e6f35ada51372 (patch) | |
| tree | 8afcbd56cf87683c9656d81c6cc95bccd5eee1cf /src/routes/(app)/migrate/+page.server.ts | |
| parent | 2c9ab7a73c662e15229c340ba471fb3aeec41b70 (diff) | |
| download | coinos-ui-efa4a719786633ba905798cdc46e6f35ada51372.tar.gz coinos-ui-efa4a719786633ba905798cdc46e6f35ada51372.zip | |
migrate: flag the account instead of renaming it
Renaming to <name>v2 was a hack for freeing the username, and v3/v4/v9
fallbacks made it worse. The page now sweeps the balance and sets the
new `migrated` flag: the registrar takes over receiving for the name
while the old account keeps working here, unchanged.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi
Diffstat (limited to 'src/routes/(app)/migrate/+page.server.ts')
| -rw-r--r-- | src/routes/(app)/migrate/+page.server.ts | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/src/routes/(app)/migrate/+page.server.ts b/src/routes/(app)/migrate/+page.server.ts index 5182e8a0..f1964d1b 100644 --- a/src/routes/(app)/migrate/+page.server.ts +++ b/src/routes/(app)/migrate/+page.server.ts @@ -20,26 +20,12 @@ async function invoiceFor(address: string, sats: number) { return inv.pr as string; } -// The server only accepts letters and numbers, 2–24 of them, so the retired -// name can't carry a separator. Candidates are <name>v2, <name>v3, … each -// trimmed to fit, so a long username still lands inside the limit. -function retiredNames(username: string) { - const base = String(username).replace(/[^\p{L}\p{N}]/gu, ""); - const out: string[] = []; - for (let n = 2; n <= 9; n++) { - const suffix = `v${n}`; - out.push(base.slice(0, 24 - suffix.length) + suffix); - } - return out; -} - export async function load({ parent, url }) { const { user } = await parent(); if (!user) redirect(307, `/login?redirect=${encodeURIComponent(url.pathname + url.search)}`); return { to: url.searchParams.get("to") || "", back: url.searchParams.get("back") || "", - newName: retiredNames(user.username)[0], }; } @@ -76,23 +62,11 @@ export const actions = { } if (!sent) throw lastErr; } - // Releasing the username is what lets them keep it on v3. If the - // retired name is itself taken, step to the next candidate. - let renamed = ""; - let renameErr; - for (const candidate of retiredNames(username)) { - try { - await post("/user", { username: candidate, ...(pin ? { pin } : {}) }, auth(cookies)); - renamed = candidate; - break; - } catch (e) { - renameErr = e; - const msg = String((e as any)?.message || e); - if (!/taken/i.test(msg)) throw e; - } - } - if (!renamed) throw renameErr; - return { ok: true, sent, released: username, renamed }; + // Hand the name over for receiving. The account itself stays exactly + // as it is — same username, same history, still usable here; the + // registrar just becomes the answer for incoming payments. + await post("/user", { migrated: true, ...(pin ? { pin } : {}) }, auth(cookies)); + return { ok: true, sent, released: username }; } catch (e) { const msg = e && typeof e === "object" && "message" in e ? String(e.message) : String(e); return { error: msg, sent }; |
