From 0904ac984bb2aff0a862a0157f8f2feead1b1c83 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 17 Sep 2020 00:55:40 -0700 Subject: use current account for internal payments --- routes/send.js | 10 +--------- routes/users.js | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'routes') diff --git a/routes/send.js b/routes/send.js index aea0a858..e2836b82 100644 --- a/routes/send.js +++ b/routes/send.js @@ -10,14 +10,7 @@ module.exports = ah(async (req, res, next) => { try { await db.transaction(async transaction => { - let account = await db.Account.findOne({ - where: { - user_id: user.id, - asset - }, - lock: transaction.LOCK.UPDATE, - transaction - }); + let { account } = user; if (account.balance < amount) { throw new Error("Insufficient funds"); @@ -149,7 +142,6 @@ module.exports = ah(async (req, res, next) => { user.username, user.balance, e.message, - e.stack ); return res.status(500).send(e.message); } diff --git a/routes/users.js b/routes/users.js index 5de71a54..e92bc874 100644 --- a/routes/users.js +++ b/routes/users.js @@ -455,7 +455,7 @@ app.post( try { const account = await db.Account.findOne({ - where: { id } + where: { id, user_id: user.id } }); user.account_id = account.id; -- cgit v1.2.3