|
|
@ -9,7 +9,7 @@ const libphonenumberjs = require("libphonenumber-js");
|
|
|
|
const boom = require("boom");
|
|
|
|
const boom = require("boom");
|
|
|
|
|
|
|
|
|
|
|
|
// Get Data Models
|
|
|
|
// Get Data Models
|
|
|
|
const { User,Counter, generateBookingId,resetCounter,generateCustomerId } = require('../models/User')
|
|
|
|
const { User,Counter, generateBookingId,resetCounter,generateCustomerId,ProfilePicture} = require('../models/User')
|
|
|
|
//const User = require("../models/User");
|
|
|
|
//const User = require("../models/User");
|
|
|
|
|
|
|
|
|
|
|
|
const customJwtAuth = require("../customAuthJwt");
|
|
|
|
const customJwtAuth = require("../customAuthJwt");
|
|
|
@ -335,3 +335,38 @@ exports.delPhoneUser = async (req, reply) => {
|
|
|
|
throw boom.boomify(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.uploadProfilePicture = async (req, reply) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
|
|
|
const picture = new Buffer.from(req.body.picture, 'base64');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const profilePicture = new ProfilePicture({ customerId, picture });
|
|
|
|
|
|
|
|
await profilePicture.save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { message: 'Profile picture uploaded successfully' };
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
reply.status(500).send({ error: error.message });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.updateProfilePicture = async (req, reply) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
|
|
|
const picture = new Buffer.from(req.body.picture, 'base64');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const profilePicture = await ProfilePicture.findOneAndUpdate({ customerId }, { picture }, { new: true });
|
|
|
|
|
|
|
|
if (!profilePicture) {
|
|
|
|
|
|
|
|
reply.status(404).send({ error: 'Profile picture not found' });
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { message: 'Profile picture updated successfully' };
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
reply.status(500).send({ error: error.message });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|