diff --git a/src/controllers/userController.js b/src/controllers/userController.js index ff80d789..0eb9c1b0 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -928,6 +928,7 @@ exports.createstaff = async (request, reply) => { name: member.name || null, phone: member.phone || null, password: member.password || null, + all_motor_access:member.all_motor_access, status: "active", // Default status }); } @@ -937,6 +938,7 @@ exports.createstaff = async (request, reply) => { return reply.status(400).send({ error: 'Duplicate phone numbers found', duplicatePhones }); } + // Update the user document with the new staff members user.staff.staff.push(...newStaff); diff --git a/src/models/User.js b/src/models/User.js index d8d9c7cc..67e8310f 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -63,11 +63,12 @@ const userSchema = new mongoose.Schema( survey_status:{ type:String,default: "pending" }, staff: { + staff: [ { name: { type: String }, phone: { type: String }, - + all_motor_access: { type: String }, password: { type: String, default: null }, status: { type: String, default: "active" }, diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index 156e6c31..cc82207e 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -851,6 +851,7 @@ module.exports = function (fastify, opts, next) { phone: { type: "string", default: null }, password:{ type: "string" ,default: null}, + all_motor_access:{ type: "string" ,default: "read"}, }, }, @@ -864,6 +865,7 @@ module.exports = function (fastify, opts, next) { }, ], }, + //preHandler: fastify.auth([fastify.authenticate]), handler: userController.createstaff, });