ashok 9 months ago
commit 90f2bdb2a7

@ -264,12 +264,14 @@ fastify.post("/api/login", {
}
}
}
// Check for staff login
const allUsers = await User.find({ "staff.staff": { $elemMatch: { phone } } });
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 +288,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",
},
});
}

@ -44,6 +44,7 @@ const generateBookingId = async () => {
const userSchema = new mongoose.Schema(
{
installationId:{type:String},

Loading…
Cancel
Save