survey login changes

master^2
Bhaskar 7 months ago
parent f0cc433316
commit d73fef94fa

@ -1138,6 +1138,7 @@ fastify.post("/api/installLogin", {
// Check if user exists in the Department Schema
const user = await Deparments.findOne({ phone });
console.log("user", user)
if (!user) {
return reply.code(400).send({ message: "User not found" });
@ -1155,7 +1156,7 @@ fastify.post("/api/installLogin", {
if (!survey) {
survey = new Survey({
phone: user.phone,
surveyId: user.surveyId,
surveyId: user.departmentId,
firstName: user.firstName,
lastName: user.lastName,
email: user.email,
@ -1178,7 +1179,7 @@ fastify.post("/api/installLogin", {
}
const token = fastify.jwt.sign(
{ phone: user.phone, surveyId: user.surveyId },
{ phone: user.phone },
"Scret",
{ expiresIn: "1h" }
);
@ -1189,7 +1190,7 @@ fastify.post("/api/installLogin", {
message: "Login successful",
access_token: token,
phone: user.phone,
surveyId: user.surveyId,
surveyId: user.departmentId,
firstName: user.firstName,
lastName: user.lastName,
email: user.email,

Loading…
Cancel
Save