This commit is contained in:
yashrajverma 2021-05-31 13:13:31 +05:30
parent 51238a4d96
commit 812cc70ae9
1 changed files with 17 additions and 9 deletions

View File

@ -224,17 +224,25 @@ module.exports.postSignin = async (req, res, next) => {
console.log("req.body", req.body); console.log("req.body", req.body);
let user = await User.findOne({ email }); let user = await User.findOne({ email });
if (isGoogle) { if (isGoogle) {
user.isVerified = true; if (user) {
user = await user.save(); user.isVerified = true;
const isMatched = await bcrypt.compare(password, user.password); user = await user.save();
if (isMatched) { const isMatched = await bcrypt.compare(password, user.password);
const token = jwt.sign({ _id: user._id }, JWT_secret); if (isMatched) {
res.json({ const token = jwt.sign({ _id: user._id }, JWT_secret);
token: token, res.json({
}); token: token,
});
} else {
res.json({
message: "email and password doesn't match",
type: "error",
});
return;
}
} else { } else {
res.json({ res.json({
message: "email and password doesn't match", message: "User Doesn't Exists",
type: "error", type: "error",
}); });
return; return;