func (this *MainController) ChangePwd() { fmt.Println("修改密码成功") userInfo := this.GetSession("userinfo") if userInfo == nil { this.Ctx.Redirect(302, beego.AppConfig.String("auth_gateway")) } oldPwd := this.GetString("oldpwd") newPwd := this.GetString("newpwd") repeatpassword := this.GetString("reppwd") if newPwd != repeatpassword { this.Rsp(false, "二次密码输入不一致") } user, err := m.CheckLogin(userInfo.(m.User).Uname, oldPwd) if err == nil { var u m.User u.Id = user.Id u.Pwd = newPwd id, err := m.UpdateUser(&u) if err == nil && id > 0 { this.Rsp(true, "密码修改成功") return } else { this.Rsp(false, err.Error()) return } } this.Rsp(false, "密码错误") }
func (this *MainController) Login() { isAjax := this.GetString("isAjax") if isAjax == "0" { uName := this.GetString("uname") pwd := this.GetString("password") user, err := m.CheckLogin(uName, pwd) if err == nil { this.SetSession("userinfo", user) accessList, _ := m.GetAccessList(user.Id) this.SetSession("accessList", accessList) this.Ctx.Redirect(302, "/cstore/mainFrame") return } else { this.Data["err"] = err this.TplNames = "err/error404.html" return } } userInfo := this.GetSession("userinfo") if userInfo != nil { this.Ctx.Redirect(302, "index.tpl") } this.TplNames = "login.html" }