Example #1
0
func (model *UserAdminModel) SetToUser(u *user.User) {
	// set md5 value if the value is an email
	if strings.IndexRune(model.GrEmail, '@') != -1 {
		model.GrEmail = utils.EncodeMd5(model.GrEmail)
	}

	utils.SetFormValues(model, u)
}
Example #2
0
func (form *ProfileForm) SaveUserProfile(u *user.User) error {
	// set md5 value if the value is an email
	if strings.IndexRune(form.GrEmail, '@') != -1 {
		form.GrEmail = utils.EncodeMd5(form.GrEmail)
	}

	changes := utils.FormChanges(u, form)
	if len(changes) > 0 {
		// if email changed then need re-active
		if u.Email != form.Email {
			u.Active = false
			changes = append(changes, "Active")
		}
		serv := &userServ.UserService{}
		utils.SetFormValues(form, u)
		return serv.Update(u, changes...)
	}
	return nil
}
Example #3
0
func (model *UserAdminModel) SetFromUser(u *user.User) {
	utils.SetFormValues(u, model)
}
Example #4
0
func (form *ProfileForm) SetFromUser(u *user.User) {
	utils.SetFormValues(u, form)
}