aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/migrate
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-12-02 10:34:36 -0700
committerAdam Soltys <[email protected]>2026-12-02 10:34:36 -0700
commit374afce1c93e25373eadce258edaa0398fb99faf (patch)
treea53eeff7db40f876b7cc55e57b50ebd4d334abb2 /src/routes/(app)/migrate
parentd707d2c696184b5ad90132cb0a4b5673d15d6644 (diff)
downloadcoinos-ui-374afce1c93e25373eadce258edaa0398fb99faf.tar.gz
coinos-ui-374afce1c93e25373eadce258edaa0398fb99faf.zip
migrate: grant the registrar the session's own name, not the form'sHEADmasterHEAD
The /migrate action told the names registrar which v3 identity may claim a name, using the `username` field from the submitted form. Any logged-in account could post another user's name and be granted it. Look the name up from the session (/me) instead, and refuse before sweeping or flagging anything when there is no session. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6SSfVopM1ZzXKZmLYU
Diffstat (limited to 'src/routes/(app)/migrate')
-rw-r--r--src/routes/(app)/migrate/+page.server.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/routes/(app)/migrate/+page.server.ts b/src/routes/(app)/migrate/+page.server.ts
index 6559485f..494eb5b8 100644
--- a/src/routes/(app)/migrate/+page.server.ts
+++ b/src/routes/(app)/migrate/+page.server.ts
@@ -1,4 +1,4 @@
-import { auth, post } from "$lib/utils";
+import { auth, get, post } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
import { env } from "$env/dynamic/private";
@@ -60,8 +60,13 @@ export const actions = {
const to = String(form.get("to") || url.searchParams.get("to") || "");
const pin = String(form.get("pin") || "");
const balance = Number(form.get("balance") || 0);
- const username = String(form.get("username") || "");
if (!to) return { error: "no destination" };
+ // The name handed to the registrar has to be the one this session is
+ // logged in as. Never take it from the form, or any account could have
+ // the registrar grant it someone else's @coinos.io name.
+ const me = await get("/me", auth(cookies)).catch(() => null);
+ const username = me?.username;
+ if (!username) return { error: "not logged in" };
let sent = 0;
try {