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