Skip to content

Commit

Permalink
Fix user update and avatar/cover image assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshchoudhary committed Dec 19, 2023
1 parent 802aa88 commit 23b80aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ const updateAccountDetails = asyncHandler(async(req, res) => {
throw new ApiError(400, "All fields are required")
}

const user = User.findByIdAndUpdate(
const user = await User.findByIdAndUpdate(
req.user?._id,
{
$set: {
Expand All @@ -288,6 +288,8 @@ const updateUserAvatar = asyncHandler(async(req, res) => {
throw new ApiError(400, "Avatar file is missing")
}

//TODO: delete old image - assignment

const avatar = await uploadOnCloudinary(avatarLocalPath)

if (!avatar.url) {
Expand Down Expand Up @@ -319,6 +321,9 @@ const updateUserCoverImage = asyncHandler(async(req, res) => {
throw new ApiError(400, "Cover image file is missing")
}

//TODO: delete old image - assignment


const coverImage = await uploadOnCloudinary(coverImageLocalPath)

if (!coverImage.url) {
Expand All @@ -343,6 +348,8 @@ const updateUserCoverImage = asyncHandler(async(req, res) => {
)
})



export {
registerUser,
loginUser,
Expand Down

0 comments on commit 23b80aa

Please sign in to comment.