From 9445d237b2065e6e300e58c5af59f46bbc0b9b3f Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 5 Feb 2025 11:06:13 +0530 Subject: [PATCH 1/2] added all motor access to staff --- src/controllers/userController.js | 1 + src/models/User.js | 2 +- src/routes/usersRoute.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controllers/userController.js b/src/controllers/userController.js index ff80d789..6b8677c4 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 }); } diff --git a/src/models/User.js b/src/models/User.js index d8d9c7cc..439559c8 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -67,7 +67,7 @@ const userSchema = new mongoose.Schema( { 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..17934849 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"}, }, }, From 38eafcbad743c62c7db4e751a7e3505fa35bcb24 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 5 Feb 2025 11:07:08 +0530 Subject: [PATCH 2/2] changes --- src/controllers/userController.js | 1 + src/models/User.js | 1 + src/routes/usersRoute.js | 1 + 3 files changed, 3 insertions(+) diff --git a/src/controllers/userController.js b/src/controllers/userController.js index 6b8677c4..0eb9c1b0 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -938,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 439559c8..67e8310f 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -63,6 +63,7 @@ const userSchema = new mongoose.Schema( survey_status:{ type:String,default: "pending" }, staff: { + staff: [ { name: { type: String }, diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index 17934849..cc82207e 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -865,6 +865,7 @@ module.exports = function (fastify, opts, next) { }, ], }, + //preHandler: fastify.auth([fastify.authenticate]), handler: userController.createstaff, });