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
func (this *PasswordRouter) Post() {
	this.Data["IsUserSettingPage"] = true
	if this.CheckLoginRedirect() {
		return
	}

	pwdForm := auth.PasswordForm{User: &this.User}

	this.Data["Form"] = pwdForm

	if this.ValidFormSets(&pwdForm) {
		// verify success and save new password
		if err := auth.SaveNewPassword(&this.User, pwdForm.Password); err == nil {
			this.FlashRedirect("/settings/change/password", 302, "PasswordSave")
			return
		} else {
			log.Error("ProfileSave: change-password", err)
		}
	}

	this.Render("settings/change_password.html", this.Data)
}