func (this *AdminController) My() { v := this.GetSession("user") if v == nil { this.Redirect("/admin/login", 302) } else { //this.Ctx.WriteString(v) user, err := models.GetUserById(v.(int)) if err == nil { this.Data["userid"] = user.Id this.Data["username"] = user.Username this.Data["nickname"] = user.Nickname this.Data["email"] = user.Email this.Data["content"] = user.Content } this.TplNames = "admin/my.tpl" } }
func (this *AdminController) Editpass() { password := this.GetString("password") new_password := this.GetString("new_password") v := this.GetSession("user") var redata Returnjson user, err := models.GetUserById(v.(int)) if err == nil { password = Md5(password) if password != user.Password { redata = Returnjson{"fail", "", "原密码错误", ""} } else { _, err := models.EditUserPassword(v.(int), Md5(new_password)) if err != nil { redata = Returnjson{"fail", "", "修改失败", ""} } else { this.DelSession("user") redata = Returnjson{"success", "/admin/login", "修改成功", ""} } } } this.Data["json"] = &redata this.ServeJson() }