name adde in team member login

master^2
Bhaskar 7 months ago
parent b9438b9322
commit de81793c5d

@ -28,7 +28,7 @@ const generateTeamMemberId = async () => {
exports.createTeamMember = async (request, reply) => { exports.createTeamMember = async (request, reply) => {
try { try {
const { installationId, name, phone, password,email,alternativePhone ,status} = request.body; const { installationId, firstName, phone, password,email,alternativePhone ,status} = request.body;
// Check if installation exists // Check if installation exists
const installation = await Install.findOne({ installationId }); const installation = await Install.findOne({ installationId });
@ -64,7 +64,7 @@ exports.createTeamMember = async (request, reply) => {
// Create new team member // Create new team member
const newTeamMember = { const newTeamMember = {
teamMemberId, teamMemberId,
name, firstName,
phone, phone,
email, email,
alternativePhone, alternativePhone,

@ -1058,7 +1058,7 @@ fastify.post("/api/teamMemberLogin", {
const teamMember = installation.team_member.team_member.find( const teamMember = installation.team_member.team_member.find(
(member) => member.phone === phone (member) => member.phone === phone
); );
console.log(installation.team_member.team_member.firstName)
if (!teamMember) { if (!teamMember) {
return reply.status(401).send({ return reply.status(401).send({
simplydata: { simplydata: {
@ -1092,7 +1092,7 @@ fastify.post("/api/teamMemberLogin", {
// Generate JWT token // Generate JWT token
const token = fastify.jwt.sign( const token = fastify.jwt.sign(
{ phone: teamMember.phone, role: type, installationId }, { phone: teamMember.phone, role: type, installationId },
process.env.JWT_SECRET, "JWT_SECRET",
{ expiresIn: "1h" } { expiresIn: "1h" }
); );

@ -9,10 +9,10 @@ module.exports = function (fastify, opts, next) {
summary: "Create Team Member", summary: "Create Team Member",
body: { body: {
type: "object", type: "object",
required: ["installationId", "name", "phone", "password"], required: ["installationId", "firstName", "phone", "password"],
properties: { properties: {
installationId: { type: "string", description: "Installation ID to associate the team member with" }, installationId: { type: "string", description: "Installation ID to associate the team member with" },
name: { type: "string", description: "Full name of the team member" }, firstName: { type: "string", description: "Full name of the team member" },
phone: { type: "string", description: "Phone number of the team member" }, phone: { type: "string", description: "Phone number of the team member" },
password: { type: "string", description: "Password for the team member" }, password: { type: "string", description: "Password for the team member" },
alternativePhone: { type: "string", }, alternativePhone: { type: "string", },

Loading…
Cancel
Save