aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-08-11 11:48:49 -0700
committerAdam Soltys <[email protected]>2020-08-11 11:48:49 -0700
commit10bfc37a656e9862051a6a58ea2acdc561092f6b (patch)
tree77018a5bc2b3d0b75802f2e34446e489ad08aa5c /routes/users.js
parent3980fec05509a060ac41f98b4dd126a13e4bc9cd (diff)
downloadcoinos-server-10bfc37a656e9862051a6a58ea2acdc561092f6b.tar.gz
coinos-server-10bfc37a656e9862051a6a58ea2acdc561092f6b.zip
check password api
Diffstat (limited to 'routes/users.js')
-rw-r--r--routes/users.js22
1 files changed, 19 insertions, 3 deletions
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));
+ })
+);