diff options
| author | Adam Soltys <[email protected]> | 2025-02-04 10:43:38 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-04 10:43:38 -0800 |
| commit | cf63622c234446c0a385cd792dceeb7e04ef72a0 (patch) | |
| tree | e9b471998c12060326df1f6dd7fedeb2031a72a8 /routes | |
| parent | 1f571a6c133f58c0b8c9717eb5c99fb7a291637a (diff) | |
| download | coinos-server-cf63622c234446c0a385cd792dceeb7e04ef72a0.tar.gz coinos-server-cf63622c234446c0a385cd792dceeb7e04ef72a0.zip | |
change nostr login kind
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/users.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/routes/users.ts b/routes/users.ts index d1c2bd96..f088d011 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -161,13 +161,15 @@ export default { async update(req, res) { const { user, body } = req; try { - const { id: tokid } = jwt.verify(req.headers.authorization.split(" ")[1], config.jwt); + const { id: tokid } = jwt.verify( + req.headers.authorization.split(" ")[1], + config.jwt, + ); l("updating user", user.username, tokid); const { confirm, password, pin, newpin, username } = body; let exists; - let { pubkey } = body; if (pubkey) { exists = await getUser(pubkey); @@ -295,7 +297,10 @@ export default { )) ) { // warn("invalid username or password attempt", username); - await appendFile("failedlogins.txt", `${Date.now()} : ${username} : ${password}\n`); + await appendFile( + "failedlogins.txt", + `${Date.now()} : ${username} : ${password}\n`, + ); return res.code(401).send({}); } @@ -333,10 +338,14 @@ export default { const { event, challenge, twofa } = req.body; const ip = req.headers["cf-connecting-ip"]; const c = await g(`challenge:${challenge}`); - const { pubkey: key } = event; + const { pubkey: key, kind } = event; + if (kind !== 27235) fail("Invalid event"); if (!c) fail("Invalid or expired login challenge"); - if (!verifyEvent(event) || event.content !== challenge) + if ( + !verifyEvent(event) || + event.tags.find((t) => t[0] === "challenge")?.[1] !== challenge + ) fail("Invalid signature or challenge mismatch."); let user = await getUser(key); |
