Beispiel #1
0
func GetUser(userId string) (apiUser *duoerlapi.User, err error) {

	user, err := users.FetchByIdHex(userId)
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}

	apiUser = toApiUser(user)

	return
}
Beispiel #2
0
func UpdateProfile(userInput *duoerlapi.UserInput) (err error) {
	user, err := users.FetchByIdHex(userInput.Id)
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}

	user.AvatarUrl = userInput.Avatar
	user.Profile.Gender = userInput.Profile.Gender
	user.Profile.Location = userInput.Profile.Location
	user.Profile.Description = userInput.Profile.Description
	user.Profile.HairTexture = userInput.Profile.HairTexture
	user.Profile.SkinTexture = userInput.Profile.SkinTexture
	user.Profile.Birthday, _ = time.Parse(global.DATE_BIRTHDAY, userInput.Profile.Birthday)

	if err = user.Save(); err != nil {
		utils.PrintStackAndError(err)
		return
	}

	return
}