firstname, lastname & alternative fields are added

master
Naidu 1 year ago
parent 03953a5aed
commit 15dc03f08e

@ -25,15 +25,18 @@ exports.installSignUp = async (request, reply) => {
longitude,
latitude,
fcmId,
alternativeNumber,
firstName,
lastName,
createdBy,
updatedBy,
} = request.body;
// Check if the email address is valid
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (emails.some((emailObj) => !emailRegex.test(emailObj.email))) {
return reply.status(400).send({ message: 'Invalid email address' });
}
// const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
// if (emails.some((emailObj) => !emailRegex.test(emailObj.email))) {
// return reply.status(400).send({ message: 'Invalid email address' });
// }
// Check if a user with the same phone number already exists
const existingInstall = await Install.findOne({ phone });
@ -58,8 +61,12 @@ exports.installSignUp = async (request, reply) => {
longitude,
latitude,
fcmId,
alternativeNumber,
firstName,
lastName,
createdBy,
updatedBy,
});
// Save the new install to the database

@ -351,6 +351,9 @@ fastify.post("/api/installotplogin", {
team: loginObject.user.team,
city:loginObject.user.city,
manager:loginObject.user.manager,
firstName:loginObject.user.firstName,
lastName:loginObject.user.lastName,
alternativeNumber:loginObject.user.alternativeNumber,
// typeasobj: JSON.parse(loginObject.user.profile.role),
},
};

@ -18,6 +18,8 @@ const installationschema = new mongoose.Schema({
profile: {
alternativeNumber: { type: String, default: null },
firstName: { type: String, default: null },
lastName: { type: String, default: null },
address1: { type: String, default: null },
address2: { type: String, default: null },
city: { type: String, default: null },

@ -38,6 +38,9 @@ module.exports = function (fastify, opts, next) {
latitude: { type: 'number', default: 0.0 },
longitude: { type: 'number', default: 0.0 },
fcmId: { type: 'string', default: null },
alternativeNumber : { type: 'string', default: null },
firstName :{ type: 'string', default: null },
lastName : { type: 'string', default: null },
},
},
security: [

Loading…
Cancel
Save