Example #1
0
File: user.go Project: rainkid/ago
func (c *User) getGroupName(groupid []byte) string {
	//group list
	mgroup := models.NewGroupModel()
	groups, err := mgroup.Gets()
	if err != nil {
		return ""
	}
	for _, group := range groups {
		if bytes.Equal(groupid, utils.ItoByte(group["groupid"])) {
			return utils.ItoString(group["name"])
		}
	}
	return ""
}
Example #2
0
File: user.go Project: rainkid/ago
func (c *User) Passwd_post() {
	values := c.GetInputs([]string{"current_password", "password", "r_password"})

	user := models.NewUserModel()
	flag, msg := user.CheckPasswd(values["current_password"])
	if !flag {
		c.Json(-1, msg, nil)
		return
	}
	flag, password := user.Password(values["password"], utils.ItoString(c.UserInfo["hash"]))
	if !flag {
		c.Json(-1, "修改失败.", nil)
		return
	}
	data := map[string]string{"password": password}
	user.Wherep(c.UserInfo["uid"]).Update(data)
	c.Json(0, "修改成功.", nil)
}