|
|
@ -35,7 +35,7 @@ exports.loadUser = async (req, res, next) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const user = await User.getUserByPhoneOrEmail({ email: req.body.email || req.body.username }); |
|
|
|
const user = await User.getUserByPhoneOrEmail({ email: req.body.email || req.body.username }); |
|
|
|
if (!user) { |
|
|
|
if (!user) { |
|
|
|
return res.status(400).json({ message: 'email incorrect' }); |
|
|
|
return res.status(400).json({ message: 'email or password is incorrect' }); |
|
|
|
} |
|
|
|
} |
|
|
|
req.locals = { |
|
|
|
req.locals = { |
|
|
|
user |
|
|
|
user |
|
|
@ -51,7 +51,7 @@ exports.checkPassword = async (req, res, next) => { |
|
|
|
// console.log(user);
|
|
|
|
// console.log(user);
|
|
|
|
const isCheck = await User.passwordMatches(user, req.body.password); |
|
|
|
const isCheck = await User.passwordMatches(user, req.body.password); |
|
|
|
if (!isCheck) { |
|
|
|
if (!isCheck) { |
|
|
|
return res.status(400).json({ message: ' password incorrect' }); |
|
|
|
return res.status(400).json({ message: 'email or password is incorrect' }); |
|
|
|
} |
|
|
|
} |
|
|
|
return next(); |
|
|
|
return next(); |
|
|
|
}; |
|
|
|
}; |
|
|
|