|
|
@ -101,7 +101,7 @@ exports.orderNow = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const insertedagent = await agent.save();
|
|
|
|
const insertedagent = await agent.save();
|
|
|
|
|
|
|
|
|
|
|
|
return insertedagent;
|
|
|
|
return insertedagent;
|
|
|
@ -127,4 +127,64 @@ exports.orderNow = async (req, reply) => {
|
|
|
|
throw boom.boomify(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.verifyPhone = async (req, reply) => {
|
|
|
|
|
|
|
|
console.log("-------------------------------------------------");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
phone = req.body.phone;
|
|
|
|
|
|
|
|
phoneVerificationCode = req.body.phoneVerificationCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if user exists in the system. If user exists , display message that
|
|
|
|
|
|
|
|
// username is not available
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
|
|
|
|
"this is the phone and verification code",
|
|
|
|
|
|
|
|
phone,
|
|
|
|
|
|
|
|
phoneVerificationCode
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
userExists = await Supplier.findOne({
|
|
|
|
|
|
|
|
phone: phone,
|
|
|
|
|
|
|
|
phoneVerified: false,
|
|
|
|
|
|
|
|
phoneVerificationCode: phoneVerificationCode,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(userExists);
|
|
|
|
|
|
|
|
if (userExists) {
|
|
|
|
|
|
|
|
// update the phoneVerified flag to true.
|
|
|
|
|
|
|
|
const filter = {
|
|
|
|
|
|
|
|
phone: phone,
|
|
|
|
|
|
|
|
phoneVerificationCode: phoneVerificationCode,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const update = { phoneVerified: true };
|
|
|
|
|
|
|
|
const doc = await Supplier.findOneAndUpdate(filter, update);
|
|
|
|
|
|
|
|
updatedUser = await Supplier.findOne({ phone: phone });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updatedUser.phoneVerified) {
|
|
|
|
|
|
|
|
reply.send('{"armintatankdata":{"error":false,"verified": true}}');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
error = {
|
|
|
|
|
|
|
|
armintatankdata: {
|
|
|
|
|
|
|
|
error: true,
|
|
|
|
|
|
|
|
code: 10005,
|
|
|
|
|
|
|
|
message: "10005 - Verification code entered cannot be validated.",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
req.body.regError = error;
|
|
|
|
|
|
|
|
reply.send(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
error = {
|
|
|
|
|
|
|
|
armintatankdata: {
|
|
|
|
|
|
|
|
error: true,
|
|
|
|
|
|
|
|
code: 10005,
|
|
|
|
|
|
|
|
message: "10005 - Verification code entered cannot be validated.",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
req.body.regError = error;
|
|
|
|
|
|
|
|
reply.send(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|