Skip to content

add /profile/updatePassword #3

@Subhamstar

Description

@Subhamstar

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);
}
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions