在个人主页这里面,新手求教
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
Go to the official website documentation, use express or koa
router.post("/changePwd", (req, res, next) => { var oldPwd = req.body.oldPwd, newPwd = req.body.newPwd, uid = req.session.user.id; var ep = new EventProxy(); ep.fail(err => { logger.error("~update user password failed .", err); res.json({status: err.status || se.code.failed}); }); if (!oldPwd || !newPwd) { return ep.throw(se.error(se.code.paramIllegal)); } if(oldPwd == newPwd){ return ep.throw(se.error(se.code.pwdSame)); } admin.findUserById(uid, ep.done(user => { if(user[0].password != encrypt.encrypt(oldPwd)){ return ep.throw(se.error(se.code.verifyFailed)); } if(user[0].password == encrypt.encrypt(newPwd)){ return ep.throw(se.error(se.code.pwdSame)); } admin.updatePassword(encrypt.encrypt(newPwd),uid,ep.done(count => { if(count > 0){ res.json({status : se.code.success}); }else{ res.json({status : se.code.failed}); } })); })); });
Return a string in json format
Go to the official website documentation, use express or koa
Return a string in json format