profileAuth.patch("/profile/updatePassword",userAuth,async(req,res)=>{
try{
const {password}=req.body;
const loggedInUser=req.user;
const isSame= await bcrypt.compare(password,loggedInUser.password,);
if(isSame){
throw new Error("Previous password and Updated password are same. Try diffferent !! ")
}
loggedInUser.password=password;
await loggedInUser.save();
res.send("Password updated Successfully");
}
catch(err){
res.status(400).send("Error : "+err.message);
}
})
profileAuth.patch("/profile/updatePassword",userAuth,async(req,res)=>{
try{
const {password}=req.body;
const loggedInUser=req.user;
const isSame= await bcrypt.compare(password,loggedInUser.password,);
if(isSame){
throw new Error("Previous password and Updated password are same. Try diffferent !! ")
}
loggedInUser.password=password;
await loggedInUser.save();
res.send("Password updated Successfully");
}
catch(err){
res.status(400).send("Error : "+err.message);
}
})