Added image bytes to update user profile
This commit is contained in:
1 parent
9532fa6fb5
commit
da1e8ee5d9
3 files changed
+15
-3
No files matched your search
@@ -88,9 +88,16 @@ const getUserByEmail = async (req, res) => {
|
||||
|
||||
const updateUser = async (req, res) => {
|
||||
const candidateUserId = req.params.userId;
|
||||
const candidateUser = req.body;
|
||||
|
||||
try {
|
||||
const candidateUser = { ...req.body };
|
||||
if (req.file) {
|
||||
candidateUser.profileImage = {
|
||||
data: req.file.buffer,
|
||||
contentType: req.file.mimetype,
|
||||
};
|
||||
}
|
||||
|
||||
const updatedUser = await UserModel.findByIdAndUpdate(
|
||||
candidateUserId,
|
||||
candidateUser,
|
||||
|
||||
@@ -16,7 +16,12 @@ const {
|
||||
//Auth routes
|
||||
router.post("/register", upload.single("profileImage"), registerController);
|
||||
router.post("/login", loginController);
|
||||
router.post("/user/:userId", verifyJWT, userEditController);
|
||||
router.post(
|
||||
"/user/:userId",
|
||||
upload.single("profileImage"),
|
||||
verifyJWT,
|
||||
userEditController
|
||||
);
|
||||
router.get("/users/admin", checkAdminController);
|
||||
|
||||
//Recovery routes
|
||||
|
||||
@@ -25,7 +25,7 @@ const editUserParamValidation = joi.object({
|
||||
const editUserBodyValidation = joi.object({
|
||||
firstname: joi.string(),
|
||||
lastname: joi.string(),
|
||||
profilePicUrl: joi.string(),
|
||||
profileImage: joi.any(),
|
||||
role: joi.string(),
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user