更新登录密码
()
| 50 | |
| 51 | //更新登录密码 |
| 52 | func (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 | //更新管理员信息 |
| 79 | func (this *LoginController) UpdateAdmin() { |
nothing calls this directly
no test coverage detected