登录后台
()
| 28 | |
| 29 | //登录后台 |
| 30 | func (this *LoginController) Login() { |
| 31 | this.EnableXSRF = true |
| 32 | this.Data["Sys"], _ = models.NewSys().Get() |
| 33 | if this.Ctx.Request.Method == "GET" { |
| 34 | this.Xsrf() |
| 35 | this.TplName = "index.html" |
| 36 | } else { |
| 37 | var ( |
| 38 | msg string = "登录失败,用户名或密码不正确" |
| 39 | admin models.Admin |
| 40 | ) |
| 41 | this.ParseForm(&admin) |
| 42 | if admin, err := models.NewAdmin().Login(admin.Username, admin.Password, admin.Code); err == nil && admin.Id > 0 { |
| 43 | this.SetSession("AdminId", admin.Id) |
| 44 | this.ResponseJson(true, "登录成功") |
| 45 | } else { |
| 46 | this.ResponseJson(false, msg) |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | //更新登录密码 |
| 52 | func (this *LoginController) UpdatePwd() { |
nothing calls this directly
no test coverage detected