Merge pull request #4 from yashrajverma/main

Resolved
This commit is contained in:
yashraj verma 2021-05-31 13:14:39 +05:30 committed by GitHub
commit e147a87dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 36 deletions

View File

@ -221,8 +221,10 @@ module.exports.postSignin = async (req, res, next) => {
try { try {
//we need email and password as input //we need email and password as input
let { email, password, isGoogle } = req.body; let { email, password, isGoogle } = req.body;
let user = await User.findOne({ email: email }); console.log("req.body", req.body);
let user = await User.findOne({ email });
if (isGoogle) { if (isGoogle) {
if (user) {
user.isVerified = true; user.isVerified = true;
user = await user.save(); user = await user.save();
const isMatched = await bcrypt.compare(password, user.password); const isMatched = await bcrypt.compare(password, user.password);
@ -238,6 +240,13 @@ module.exports.postSignin = async (req, res, next) => {
}); });
return; return;
} }
} else {
res.json({
message: "User Doesn't Exists",
type: "error",
});
return;
}
} else { } else {
if (user) { if (user) {
if (user.isVerified) { if (user.isVerified) {
@ -295,13 +304,11 @@ module.exports.postSignin = async (req, res, next) => {
// Phone verification Starts. // Phone verification Starts.
// ----------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
module.exports.sendOTP = async (req, res, next) => { module.exports.sendOTP = (req, res, next) => {
//uNNYosMopvvCW9RTR1tRWJmYC test //uNNYosMopvvCW9RTR1tRWJmYC test
//llVKD53ve6QRpbCKOHzWBADaS live //llVKD53ve6QRpbCKOHzWBADaS live
const { phoneNumber, _id } = req.body; const { phoneNumber } = req.body;
try { try {
let user = await User.findOne({ _id });
if (user) {
if (!phoneNumber) { if (!phoneNumber) {
res.status(422).json({ message: "Please Add All Required Fields" }); res.status(422).json({ message: "Please Add All Required Fields" });
return; return;
@ -322,10 +329,6 @@ module.exports.sendOTP = async (req, res, next) => {
} }
); );
} }
} else {
res.status(422).json({ error: "User Doesn't Exists!" });
return;
}
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }