From 6ac2eb0e65478d289afc8c4334fac81661f71568 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Wed, 18 Dec 2024 12:18:57 +0530 Subject: [PATCH] fix: do not allow user creation without nostr pubkey --- src/users.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/users.ts b/src/users.ts index f6bc2e7..a761e92 100644 --- a/src/users.ts +++ b/src/users.ts @@ -22,15 +22,16 @@ export function createUsersApp(db: DB, nwcPool: NWCPool) { } let nostrPubkey = createUserRequest.nostrPubkey + if (!nostrPubkey) { + return c.text("no nostr pubkey provided", 400); + } - if (nostrPubkey) { - if (nostrPubkey.startsWith("npub")) { - nostrPubkey = nip19.decode(nostrPubkey).data as string - } - - if (!isValid32ByteHex(nostrPubkey)) { - return c.text("invalid nostr pubkey provided", 400); - } + if (nostrPubkey.startsWith("npub")) { + nostrPubkey = nip19.decode(nostrPubkey).data as string + } + + if (!isValid32ByteHex(nostrPubkey)) { + return c.text("invalid nostr pubkey provided", 400); } const user = await db.createUser(