changes in login for staff

master^2
Varun 7 months ago
parent cd505dcab4
commit c6055ac5ca

@ -289,6 +289,7 @@ exports.loginUser = async (req, fcmIds, deviceId) => {
// If not a main user, check staff inside all users
if (!user) {
const users = await User.find({ "staff.staff.phone": phone });
for (const u of users) {
const foundStaff = u.staff.staff.find((s) => s.phone === phone);
@ -301,7 +302,6 @@ exports.loginUser = async (req, fcmIds, deviceId) => {
}
}
// If no user or staff found, return invalid credentials
if (!user) return { same: false };
@ -324,6 +324,9 @@ exports.loginUser = async (req, fcmIds, deviceId) => {
throw boom.boomify(err);
}
};
exports.loginUserWithOTP = async (req) => {
try {
const phone = req.body.phone;

@ -202,7 +202,7 @@ fastify.post("/api/login", {
simplydata: {
error: false,
phoneVerified: false,
phone: user.phone,
phone: loginObject.isStaff ? loginObject.staffMember.phone : user.phone,
oneTimePasswordSetFlag,
message: "Please Verify your phone number",
},
@ -214,7 +214,7 @@ fastify.post("/api/login", {
simplydata: {
error: false,
phoneVerified,
phone: user.phone,
phone: loginObject.isStaff ? loginObject.staffMember.phone : user.phone,
oneTimePasswordSetFlag: true,
message: "Password must be reset",
},
@ -237,7 +237,7 @@ fastify.post("/api/login", {
access_token: token,
buildingName: user.buildingName,
email: user.emails,
phone: user.phone,
phone: loginObject.isStaff ? loginObject.staffMember.phone : user.phone,
customerId: user.customerId,
username: loginObject.isStaff ? loginObject.staffMember.name : user.username,
address1: user.profile.address1,
@ -251,7 +251,10 @@ fastify.post("/api/login", {
},
};
if (loginObject.isStaff) {
responsePayload.simplydata.all_motor_access = loginObject.staffMember.all_motor_access;
}
if (profilePicture) {
responsePayload.simplydata.picture = profilePicture.picture;
}
@ -263,6 +266,7 @@ fastify.post("/api/login", {
fastify.post("/api/installotplogin", {
schema: {
description: "This is for Login Otp Installation",

Loading…
Cancel
Save