Пример #1
0
func AdminProfile(context *GoInk.Context) {
	uid, _ := strconv.Atoi(context.Cookie("token-user"))
	user := model.GetUserById(uid)
	if context.Method == "POST" {
		data := context.Input()
		if !user.ChangeEmail(data["email"]) {
			Json(context, false).Set("msg", "邮箱与别的用户重复").End()
			return
		}
		user.Name = data["user"]
		user.Email = data["email"]
		user.Avatar = utils.Gravatar(user.Email, "180")
		user.Url = data["url"]
		user.Nick = data["nick"]
		user.Bio = data["bio"]
		Json(context, true).End()
		go model.SyncUsers()
		return
	}
	context.Layout("admin")
	context.Render("admin/profile", map[string]interface{}{
		"Title": "个性资料",
		"User":  user,
	})
}
Пример #2
0
func AdminPassword(context *GoInk.Context) {
	if context.Method == "POST" {
		uid, _ := strconv.Atoi(context.Cookie("token-user"))
		user := model.GetUserById(uid)
		if !user.CheckPassword(context.String("old")) {
			Json(context, false).Set("msg", "旧密码错误").End()
			return
		}
		user.ChangePassword(context.String("new"))
		go model.SyncUsers()
		Json(context, true).End()
		return
	}
	context.Layout("admin")
	context.Render("admin/password", map[string]interface{}{
		"Title": "修改密码",
		//"User":user,
	})
}