Skip to content

Commit

Permalink
fix: do not allow user creation without nostr pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Dec 18, 2024
1 parent aa631a8 commit 6ac2eb0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6ac2eb0

Please sign in to comment.