first commit

This commit is contained in:
pawan-dot 2022-08-05 17:00:19 +05:30
parent b8838a303b
commit 8f8ceeb78c

View File

@ -38,19 +38,20 @@ export const loginUser = catchAsyncErrors(async (req, res, next) => {
// checking if user has given password and email both // checking if user has given password and email both
if (!email || !password) { if (!email || !password) {
return next(new ErrorHander("Please Enter Email & Password", 400)); return next(res.status(400).json({ message: 'Please Enter Email & Password' }));
} }
const user = await User.findOne({ email }).select("+password"); const user = await User.findOne({ email }).select("+password");
if (!user) { if (!user) {
return next(new ErrorHander("Invalid email or password", 401)); return res.status(400).json({ message: 'Invalid Email or Password' });
} }
const isPasswordMatched = await user.comparePassword(password); const isPasswordMatched = await user.comparePassword(password);
if (!isPasswordMatched) { if (!isPasswordMatched) {
return next(new ErrorHander("Invalid email or password", 401)); return res.status(400).json({ message: 'Invalid Email or Password' });
} }
// const token = user.getJWTToken(); // const token = user.getJWTToken();
// res.status(201).json({ // res.status(201).json({