aboutsummaryrefslogtreecommitdiffstats
path: root/lib/register.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-02 13:19:16 -0700
committerAdam Soltys <[email protected]>2026-11-02 13:19:16 -0700
commit10218ae86b464b8e3d29c27513eb5cc0554d044b (patch)
tree4b7525c2d716c68a1ccbe6540e7f60c211fd2dc5 /lib/register.ts
parente3ab990961397ba821faaf3cee7d872175f77ffa (diff)
downloadcoinos-server-10218ae86b464b8e3d29c27513eb5cc0554d044b.tar.gz
coinos-server-10218ae86b464b8e3d29c27513eb5cc0554d044b.zip
users: ignore pubkey on signup, revoke a rekeyed account's nostr key
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6VN9xvnX1cgvV6hrUV
Diffstat (limited to 'lib/register.ts')
-rw-r--r--lib/register.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/register.ts b/lib/register.ts
index a9e9d7f7..bb9ce4b8 100644
--- a/lib/register.ts
+++ b/lib/register.ts
@@ -24,6 +24,17 @@ export default async (user, ip) => {
if (isReserved(username)) fail("Invalid username");
if (username.includes("undefined")) fail("Invalid username");
+ // Keys revoked by changeid() belong to compromised accounts, and a key that
+ // already resolves to a live account must not be re-pointed at a new one.
+ if (pubkey) {
+ const holder = await db.get(`user:${pubkey}`);
+ if (
+ (await db.sIsMember("revoked:pubkeys", pubkey)) ||
+ (holder && (await db.exists(`user:${holder.replace(/"/g, "")}`)))
+ )
+ fail("Key in use by another account");
+ }
+
const id = v4();
user.id = id;