|
|
@ -144,7 +144,7 @@ exports.loginSupplier = async(request, reply) =>{
|
|
|
|
message: "Please Verify your phone number",
|
|
|
|
message: "Please Verify your phone number",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (!oneTimePasswordSetFlag) {
|
|
|
|
} else if (oneTimePasswordSetFlag) {
|
|
|
|
reply.send({
|
|
|
|
reply.send({
|
|
|
|
simplydata: {
|
|
|
|
simplydata: {
|
|
|
|
error: false,
|
|
|
|
error: false,
|
|
|
@ -349,7 +349,7 @@ exports.validatePhoneFormat = async (req, reply) => {
|
|
|
|
code: 10002,
|
|
|
|
code: 10002,
|
|
|
|
message:
|
|
|
|
message:
|
|
|
|
"10002 - Phone # " +
|
|
|
|
"10002 - Phone # " +
|
|
|
|
user.phone +
|
|
|
|
supplier.phone +
|
|
|
|
" is not a valid phone number",
|
|
|
|
" is not a valid phone number",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -463,3 +463,61 @@ exports.logoutsupplier = async (request, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
supplierExists = await Supplier.findOne({
|
|
|
|
|
|
|
|
phone: phone,
|
|
|
|
|
|
|
|
phoneVerified: false,
|
|
|
|
|
|
|
|
phoneVerificationCode: phoneVerificationCode,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(supplierExists);
|
|
|
|
|
|
|
|
if (supplierExists) {
|
|
|
|
|
|
|
|
// update the phoneVerified flag to true.
|
|
|
|
|
|
|
|
const filter = {
|
|
|
|
|
|
|
|
phone: phone,
|
|
|
|
|
|
|
|
phoneVerificationCode: phoneVerificationCode,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const update = { phoneVerified: true };
|
|
|
|
|
|
|
|
const doc = await Supplier.findOneAndUpdate(filter, update);
|
|
|
|
|
|
|
|
updatedSupplier = await Supplier.findOne({ phone: phone });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updatedSupplier.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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|