MCPcopy Create free account
hub / github.com/TruthHun/DocHub / UpdatePwd

Method UpdatePwd

controllers/AdminControllers/LoginController.go:52–76  ·  view source on GitHub ↗

更新登录密码

()

Source from the content-addressed store, hash-verified

50
51//更新登录密码
52func (this *LoginController) UpdatePwd() {
53 if this.AdminId > 0 {
54 PwdOld := this.GetString("password_old")
55 PwdNew := this.GetString("password_new")
56 PwdEnsure := this.GetString("password_ensure")
57 if PwdOld == PwdNew || PwdNew != PwdEnsure {
58 this.ResponseJson(false, "新密码不能与原密码相同,且确认密码必须与新密码一致")
59 } else {
60 var admin = models.Admin{Password: helper.MD5Crypt(PwdOld)}
61 if orm.NewOrm().Read(&admin, "Password"); admin.Id > 0 {
62 admin.Password = helper.MD5Crypt(PwdNew)
63 if rows, err := orm.NewOrm().Update(&admin); rows > 0 {
64 this.ResponseJson(true, "密码更新成功")
65 } else {
66 this.ResponseJson(false, "密码更新失败:"+err.Error())
67 }
68
69 } else {
70 this.ResponseJson(false, "原密码不正确")
71 }
72 }
73 } else {
74 this.Error404()
75 }
76}
77
78//更新管理员信息
79func (this *LoginController) UpdateAdmin() {

Callers

nothing calls this directly

Calls 3

UpdateMethod · 0.80
ResponseJsonMethod · 0.45
Error404Method · 0.45

Tested by

no test coverage detected