Exemplo n.º 1
0
func (r *ResetController) Get() {

	token := r.GetString("token")
	user, err := rbacModels.UserGetByResetPassToken(token)

	if user.Id == 0 || err != nil {
		r.Data["user_not_found"] = true
	} else {
		r.Data["user_not_found"] = false
	}

	r.Layout = r.GetTemplate() + "/public/base.tpl.html"
	r.TplNames = r.GetTemplate() + "/public/reset.tpl.html"
	r.Render()
}
Exemplo n.º 2
0
func (r *ResetController) Post() {

	token := r.GetString("token")
	user, err := rbacModels.UserGetByResetPassToken(token)
	if user.Id == 0 || err != nil {
		return
	}

	pass := r.GetString("password")
	confirm_pass := r.GetString("confirm_password")

	if pass == confirm_pass && len(pass) > 0 {
		if err := user.UpdatePassword(pass); err == nil {

			user.ClearResetPassToken()

			r.Data["json"] = &map[string]interface{}{"status": "success", "message": "password updated successfully"}
			r.ServeJson()
		}
	}
}