You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not too sure why we cannot call user.then as user appears return a promise. Interested to hear if anyone can advise.
As a workaround, I have simplified the control flow.
/** * PUT /account * Update profile information OR change password. */exports.accountPut=function(req,res,next){if("password"inreq.body){req.assert("password","Password must be at least 4 characters long").len(4);req.assert("confirm","Passwords must match").equals(req.body.password);}else{req.assert("email","Email is not valid").isEmail();req.assert("email","Email cannot be blank").notEmpty();req.sanitize("email").normalizeEmail({remove_dots: false});}consterrors=req.validationErrors();if(errors){req.flash("error",errors);returnres.redirect("/account");}letd={email: req.body.email,name: req.body.name,gender: req.body.gender,location: req.body.location,website: req.body.website};if("password"inreq.body){d={password: req.body.password};}constuser=newUser({id: req.user.id});user.save(d,{patch: true}).then(()=>{if("password"inreq.body){req.flash("success",{msg: "Your password has been changed."});}else{req.flash("success",{msg: "Your profile information has been updated."});}res.redirect("/account");}).catch(err=>{if(err.code==="ER_DUP_ENTRY"){req.flash("error",{msg: "The email address you have entered is already associated with another account."});}});};
Any profile updates (press update profile button) fails with the below exception. This is true for "Profile Information" and "Change Password".
Stack: Node, Express, Bootstrap, no css or js frameworks, Mocha, MySQL
Node: v6.3.1
The text was updated successfully, but these errors were encountered: