From 1872c9ae358560768d3bceb97ec5e7aff7fe453a Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Wed, 21 May 2025 14:28:24 +0530 Subject: [PATCH] support login --- src/index.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index d464523d..664bfac8 100644 --- a/src/index.js +++ b/src/index.js @@ -1533,16 +1533,30 @@ fastify.post("/api/teamMemberLogin", { summary: "Login for Support TeamMember", body: { type: "object", - required: ["phone", "password"], + required: ["type", "phone", "password"], properties: { - phone: { type: "string", description: "Registered phone number" }, - password: { type: "string", description: "Password for authentication" }, - }, - }, + type: { + type: "string", + description: "Role type of the user (e.g., 'team_member')" + }, + phone: { + type: "string", + description: "Registered phone number of the team member" + }, + password: { + type: "string", + description: "Password for authentication" + } + } + } }, async handler(req, reply) { try { - const { phone, password } = req.body; + const { type, phone, password } = req.body; + + if (type !== "Support_TeamMember") { + return reply.code(400).send({ error: "Invalid user type" }); + } const support = await Support.findOne({ "team_member.team_member.phone": phone @@ -1573,7 +1587,8 @@ fastify.post("/api/teamMemberLogin", { { support_teamMemberId: teamMember.support_teamMemberId, name: teamMember.name, - phone: teamMember.phone + phone: teamMember.phone, + type: "Support_TeamMember" }, "JWT_SECRET", { expiresIn: '7d' } @@ -1593,6 +1608,7 @@ fastify.post("/api/teamMemberLogin", { } }); + fastify.post("/api/storelogin", { schema: {