From 7ee2003f89da03ee91daf91cd4c091a457adf7e3 Mon Sep 17 00:00:00 2001 From: nguyendacthienngan Date: Wed, 29 Dec 2021 15:48:46 +0700 Subject: [PATCH] Fix bug --- controllers/users.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/users.controller.js b/controllers/users.controller.js index baec824..4e713dc 100644 --- a/controllers/users.controller.js +++ b/controllers/users.controller.js @@ -59,7 +59,7 @@ exports.login = async function (request, response) { const checkPassword = await bcrypt.compare(request.body.password, account.password); if (!checkPassword) return response.status(422).send('Password is not correct'); try { - let user = await User.findOne({user_id: account._id}); + let user = await User.findOne({_id: account.user_id}); if (user) { const token = jwt.sign({_id: user._id}, process.env.TOKEN_SECRET, { expiresIn: 60 * 60 * 24 }); //outdated in 1 day const result = {