| 87 | }; |
| 88 | |
| 89 | export const updateProfile= async(req,res)=>{ |
| 90 | try{ |
| 91 | const {profilePic}=req.body; |
| 92 | const userId=req.user._id; |
| 93 | |
| 94 | if(!profilePic){ |
| 95 | return res.status(400).json({message:"Profile pic is required"}); |
| 96 | } |
| 97 | |
| 98 | const uploadResponse= await cloudinary.uploader.upload(profilePic); |
| 99 | const updatedUser = await User.findByIdAndUpdate(userId,{profilePic:uploadResponse.secure_url},{new:true}); |
| 100 | |
| 101 | res.status(200).json(updatedUser); |
| 102 | }catch(error){ |
| 103 | console.log("error in update profile:",error); |
| 104 | res.status(500).json({message:"Internal Server Error"}); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | export const checkAuth=(req,res)=>{ |
| 109 | try{ |