Ejemplo n.º 1
0
Archivo: auth.go Proyecto: zeuson/wego
// Reset implemented user password reset.
func (this *ResetRouter) Post() {
	code := this.GetString(":code")
	this.Data["Code"] = code

	var user models.User

	if auth.VerifyUserResetPwdCode(&user, code) {
		this.Data["Success"] = true

		form := auth.ResetPwdForm{}
		if this.ValidFormSets(&form) == false {
			return
		}

		user.IsActive = true
		user.Rands = models.GetUserSalt()

		if err := auth.SaveNewPassword(&user, form.Password); err != nil {
			log.Error("ResetPost Save New Password: "******"/login", 302, "ResetSuccess")

	} else {
		this.Data["Success"] = false
	}

	this.Render("auth/reset.html", this.Data)
}
Ejemplo n.º 2
0
Archivo: auth.go Proyecto: zeuson/wego
// Active implemented check Email actice code.
func (this *RegisterActive) Get() {
	// no need active
	if this.CheckActiveRedirect(false) {
		return
	}

	code := this.Params().Get(":code")

	var user models.User

	if auth.VerifyUserActiveCode(&user, code) {
		user.IsActive = true
		user.Rands = models.GetUserSalt()
		if err := models.UpdateById(user.Id, user, models.Obj2Table([]string{"IsActive", "Rands", "Updated"})...); err != nil {
			log.Error("Active: user Update ", err)
		}
		if this.IsLogin {
			this.User = user
		}

		this.Redirect("/active/success", 302)

	} else {
		this.Data["Success"] = false
	}

	this.Render("auth/active.html", this.Data)
}
Ejemplo n.º 3
0
Archivo: form.go Proyecto: zeuson/wego
func (form *ProfileForm) SaveUserProfile(user *models.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(user, form)
	if len(changes) > 0 {
		// if email changed then need re-active
		if user.Email != form.Email {
			user.IsActive = false
			changes = append(changes, "IsActive")
		}

		utils.SetFormValues(form, user)
		return models.UpdateById(user.Id, user, changes...)
	}
	return nil
}