@ -1,5 +1,5 @@
//Get the data models
const { Supplier } = require ( '../models/supplier' ) ;
const { Supplier , DeliveryBoy } = require ( '../models/supplier' ) ;
const { FriendRequest } = require ( '../models/supplier' )
const { ProfilePicture } = require ( '../models/User' )
const supplierController = require ( "../controllers/supplierController" ) ;
@ -633,7 +633,65 @@ exports.logoutsupplier = async (request, reply) => {
throw boom . boomify ( err ) ;
}
} ;
exports . deliveryBoyVerifyPhone = 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
) ;
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 } ) ;
if ( updatedDeliveryBoy . 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 ) ;
}
} ;
// Get current supplier
exports . getCurrentSupplier = async ( req , reply ) => {