From 15a035c310e3d31219f8b535b47f1efdb14dd9e0 Mon Sep 17 00:00:00 2001 From: Varun Date: Fri, 10 Jan 2025 15:48:15 +0530 Subject: [PATCH 1/2] changes in login ,added staff login to main login --- src/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/index.js b/src/index.js index 89978d64..110bff45 100644 --- a/src/index.js +++ b/src/index.js @@ -270,6 +270,7 @@ fastify.post("/api/login", { for (const currentUser of allUsers) { const staffMember = currentUser.staff.staff.find(staff => staff.phone === phone && staff.status === "active"); if (staffMember && staffMember.password === password) { + const token = fastify.jwt.sign( { name: staffMember.name, @@ -286,7 +287,21 @@ fastify.post("/api/login", { name: staffMember.name, phone: staffMember.phone, customerId: currentUser.customerId, + + buildingName: currentUser.buildingName, + email: currentUser.emails, + + + + address1: currentUser.address1, + address2: currentUser.address2, + phoneVerified: true, + + latitude: currentUser.latitude, + longitude: currentUser.longitude, + type: "staff", message: "Staff login successful", + }, }); } From 8b3ef81b21104eb814b3b49b19f2fb2993b790a3 Mon Sep 17 00:00:00 2001 From: Varun Date: Fri, 10 Jan 2025 15:49:04 +0530 Subject: [PATCH 2/2] changes --- src/index.js | 1 + src/models/User.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 110bff45..477c4bd9 100644 --- a/src/index.js +++ b/src/index.js @@ -264,6 +264,7 @@ fastify.post("/api/login", { } } } + // Check for staff login const allUsers = await User.find({ "staff.staff": { $elemMatch: { phone } } }); diff --git a/src/models/User.js b/src/models/User.js index 5dce58ff..eab08b7a 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -44,6 +44,7 @@ const generateBookingId = async () => { + const userSchema = new mongoose.Schema( { installationId:{type:String},