delivery boy login and phone verify

master
Bhaskara Kishore 3 years ago
parent 2881cf88c6
commit 3bcc274e51

@ -71,6 +71,9 @@ exports.orderNow = async (req, reply) => {
state:req.body.state,
zip:req.body.zip,
status:req.body.status,
longitude: req.body.longitude,
latitude:req.body.latitude,
};
var agent_mobile = req.body.phone
@ -96,7 +99,8 @@ exports.orderNow = async (req, reply) => {
agent.state = usertobeInserted.state
agent.zip = usertobeInserted.zip
agent.status = usertobeInserted.status
agent.longitude = usertobeInserted.longitude
agent.latitude = usertobeInserted.latitude
}
}

@ -238,6 +238,33 @@ exports.loginSupplier = async(request, reply) =>{
//Login Delivery Handler
exports.loginDeliveryBoy = async(request, reply) =>{
phone = request.body.phone;
phoneVerificationCode = request.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
);
deliveryBoyExists = await DeliveryBoy.findOne({
phone: phone,
phoneVerified: false,
phoneVerificationCode: phoneVerificationCode,
});
console.log(deliveryBoyExists);
if (deliveryBoyExists) {
// update the phoneVerified flag to true.
const filter = {
phone: phone,
phoneVerificationCode: phoneVerificationCode,
};
const update = { phoneVerified: true };
const doc = await DeliveryBoy.findOneAndUpdate(filter, update);
updatedDeliveryBoy = await DeliveryBoy.findOne({ phone: phone });
}
loginObject = await supplierController.loginDeliveryBoy(request);
console.log("loginObject...",loginObject)
if (loginObject.same) {
@ -308,7 +335,9 @@ exports.loginDeliveryBoy = async(request, reply) =>{
address: loginObject.delivery.address,
phoneVerified: loginObject.delivery.phoneVerified,
oneTimePasswordSetFlag: loginObject.delivery.oneTimePasswordSetFlag,
supplierId: loginObject.delivery.supplierId,
longitude:loginObject.delivery. longitude,
latitude:loginObject.delivery.latitude,
},
});
}if (profilePicture) {
@ -324,6 +353,9 @@ exports.loginDeliveryBoy = async(request, reply) =>{
address: loginObject.delivery.address,
phoneVerified: loginObject.delivery.phoneVerified,
oneTimePasswordSetFlag: loginObject.delivery.oneTimePasswordSetFlag,
supplierId: loginObject.delivery.supplierId,
longitude:loginObject.delivery. longitude,
latitude:loginObject.delivery.latitude,
},
});
}
@ -664,7 +696,7 @@ exports.logoutsupplier = async (request, reply) => {
const doc = await DeliveryBoy.findOneAndUpdate(filter, update);
updatedDeliveryBoy = await DeliveryBoy.findOne({ phone: phone });
if (updatedDeliveryBoy.phoneVerified) {
if (updatedDeliveryBoy.phoneVerified) {
reply.send('{"armintatankdata":{"error":false,"verified": true}}');
} else {
error = {
@ -677,16 +709,6 @@ exports.logoutsupplier = async (request, reply) => {
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);

@ -121,6 +121,8 @@ const supplierSchema = new mongoose.Schema(
zip: { type: String, default: null },
timestamp: { type: Date, default: Date.now },
status: { type: String, default: "Inactive" },
longitude: { type : Number},
latitude: {type: Number},
});

@ -85,7 +85,8 @@ module.exports = function (fastify, opts, next) {
state: { type: "string", default: null },
zip: { type: "string", default: null },
status: { type: "string" },
latitude: { type: 'number' },
longitude: { type: 'number'}
},
},

@ -161,6 +161,7 @@ module.exports = function (fastify, opts, next) {
type: "object",
required: ["phone"],
properties: {
phoneVerificationCode: { type: "string" },
phone: { type: "string" },
},
},

Loading…
Cancel
Save