diff options
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/bitcoin/send.js | 2 | ||||
| -rw-r--r-- | routes/users.js | 22 |
2 files changed, 20 insertions, 4 deletions
diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js index ddf07f3c..2d539d5a 100644 --- a/routes/bitcoin/send.js +++ b/routes/bitcoin/send.js @@ -53,7 +53,7 @@ module.exports = ah(async (req, res) => { await account.save({ transaction }); params = { - amount: -total, + amount: -amount, fee, memo, account_id: account.id, diff --git a/routes/users.js b/routes/users.js index 36184ab4..ececd37b 100644 --- a/routes/users.js +++ b/routes/users.js @@ -369,10 +369,14 @@ app.post( const { id } = req.body; try { - const account = await db.Account.update(req.body, { + await db.Account.update(req.body, { where: { id, user_id: user.id }, }); + const account = await db.Account.findOne({ + where: { id }, + }); + emit(user.username, "account", account); res.end(); } catch (e) { @@ -410,9 +414,9 @@ app.post( user.payments = payments; user.account = account; - console.log(user.account.id); - + emit(user.username, "account", account.get({ plain: true })); emit(user.username, "user", user); + res.end(); } catch (e) { l.error(e.message); @@ -525,3 +529,15 @@ app.post( }); }) ); + +app.post( + "/password", + auth, + ah(async function (req, res) { + const { user } = req; + const { password } = req.body; + + if (!user.password) return res.send(true); + res.send(await bcrypt.compare(password, user.password)); + }) +); |
