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