ADD: redis client and inject the login-attempt logic into loginUser function
This commit is contained in:
@@ -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, {})
|
||||
|
||||
Reference in New Issue
Block a user