From de7435e34580e1a9b4b8d95b2a5013112414098f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 11 Feb 2025 13:40:05 -0800 Subject: default app on register --- routes/users.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'routes/users.ts') diff --git a/routes/users.ts b/routes/users.ts index c0d99b7d..9f5905bf 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -179,16 +179,12 @@ export default { else fail("Key in use by another account"); } - const { challenge } = body; const event = JSON.parse(body.event); + const challenge = event.tags.find((t) => t[0] === "challenge")[1]; const c = await g(`challenge:${challenge}`); - if (!c) fail("Invalid or expired login challenge"); + if (!c) fail("Invalid or expired challenge"); - if ( - !verifyEvent(event) || - event.content !== challenge || - event.pubkey !== pubkey - ) + if (!verifyEvent(event) || event.pubkey !== pubkey) fail("Invalid signature or challenge mismatch."); pubkey = pubkey.replace(/\s*/g, ""); @@ -332,7 +328,7 @@ export default { res.send({ challenge: id }); }, - async nostrLogin(req, res) { + async nostrAuth(req, res) { try { const { event, challenge, twofa } = req.body; const ip = req.headers["cf-connecting-ip"]; -- cgit v1.2.3