diff --git a/src/index.js b/src/index.js index b01b34a2..d01bbc19 100644 --- a/src/index.js +++ b/src/index.js @@ -210,17 +210,29 @@ fastify.post("/api/login", { var stringToJsonObject = JSON.parse(arrayToString); // convert string to json object var c_id = loginObject.user.customerId var profilePicture = await ProfilePicture.findOne({ customerId:c_id}); - - // console.log({ - // username: loginObject.user.username, - // roles: loginObject.user.profile.role, - // rolesasobj: stringToJsonObject, - // }); - // console.log("sending token \n"); - // console.log(token); - reply.send({ - simplydata: { - error: false, + if (!profilePicture) { + reply.send({ + simplydata: { + error: false, + apiversion: fastify.config.APIVERSION, + access_token: token, + + email: loginObject.user.emails, + phone: loginObject.user.phone, + customerId: loginObject.user.customerId, + username: loginObject.user.username, + address1: loginObject.user.profile.address1, + address2: loginObject.user.profile.address2, + phoneVerified: loginObject.user.phoneVerified, + oneTimePasswordSetFlag: loginObject.user.oneTimePasswordSetFlag, + type: loginObject.user.profile.role, + typeasobj: stringToJsonObject, + }, + }); + }if (profilePicture) { + reply.send({ + simplydata: { + error: false, apiversion: fastify.config.APIVERSION, access_token: token, picture:profilePicture.picture, @@ -234,8 +246,18 @@ fastify.post("/api/login", { oneTimePasswordSetFlag: loginObject.user.oneTimePasswordSetFlag, type: loginObject.user.profile.role, typeasobj: stringToJsonObject, - }, - }); + }, + }); + } + + // console.log({ + // username: loginObject.user.username, + // roles: loginObject.user.profile.role, + // rolesasobj: stringToJsonObject, + // }); + // console.log("sending token \n"); + // console.log(token); + } } else { error = {