From acd0ed7c156ae645e536dd01e8e846c586bc6450 Mon Sep 17 00:00:00 2001 From: varun Date: Wed, 21 Aug 2024 01:57:30 -0400 Subject: [PATCH] moved create user ti install --- src/controllers/userController.js | 2 ++ src/models/User.js | 1 + src/routes/usersRoute.js | 13 +++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/controllers/userController.js b/src/controllers/userController.js index 3ebae2ad..3ad1f8a2 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -172,6 +172,7 @@ exports.addUser = async (req, reply) => { var customer_id = `AWSU${building}${c_id}` // console.log("This is the reply in the handler after the validations", reply); userData = { + installationId:req.params.installationId, customerId: customer_id, username: req.body.username, emails: req.body.emails, @@ -208,6 +209,7 @@ exports.addUser = async (req, reply) => { if (checkFormEncoding.isUserFormUrlEncoded) { usertobeInserted = checkFormEncoding.user; console.log("thsi true url string"); + user.installationId = usertobeInserted.installationId; user.username = usertobeInserted.username; user.firstName = usertobeInserted.firstName; user.lastName = usertobeInserted.lastName; diff --git a/src/models/User.js b/src/models/User.js index 2d3f1c43..026f6e29 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -43,6 +43,7 @@ const generateBookingId = async () => { const userSchema = new mongoose.Schema( { + installationId:{type:String}, username: { type: String }, phone: { type: String, unique: true, trim: true }, address: String, diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index 70f7b944..0144ccb2 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -123,11 +123,20 @@ module.exports = function (fastify, opts, next) { fastify.route({ method: "POST", - url: "/api/users", + url: "/api/users/:installationId", schema: { - tags: ["User"], + tags: ["Install"], description: "This is for cretae New user", summary: "This is for Create New User.", + params: { + type: "object", + properties: { + installationId: { + type: "string", + description: "installationId", + }, + }, + }, body: { type: "object", properties: {