From 8fae7769fdef268912a5d33f55abeffca186f756 Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Tue, 24 Dec 2024 19:29:59 +0330 Subject: [PATCH] ADD: redis client and inject the login-attempt logic into loginUser function --- components/user/userService.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/user/userService.js b/components/user/userService.js index 2d55549..ddd6dd3 100644 --- a/components/user/userService.js +++ b/components/user/userService.js @@ -1,6 +1,7 @@ // userService.js const User = require('./userModel') const AppError = require('../../globalErrorHandler/AppError') +const redisClient = require('../../setup/redis') const jwt = require('jsonwebtoken') const bcrypt = require('bcryptjs') const maxAge = 60 * 60 * 24 * 90 @@ -85,9 +86,9 @@ const loginUser = async (email, password) => { const user = await User.findOne({ email }, null, null).select('+password') - // if (email) { - // await loginAttempt(email) - // } + if (email) { + await loginAttempt(email) + } if (!user || !(await bcrypt.compare(password, user.password))) { throw new AppError('IncorrectEmailOrPassword', 401, {})