func ForgotPasswdPost(ctx *context.Context) {
	ctx.Data["Title"] = ctx.Tr("auth.forgot_password_title")

	if setting.MailService == nil {
		ctx.NotFound("ForgotPasswdPost", nil)
		return
	}
	ctx.Data["IsResetRequest"] = true

	email := ctx.Query("email")
	ctx.Data["Email"] = email

	u, err := models.GetUserByEmail(email)
	if err != nil {
		if models.IsErrUserNotExist(err) {
			ctx.Data["ResetPwdCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, ctx.Locale.Language())
			ctx.Data["IsResetSent"] = true
			ctx.HTML(http.StatusOK, tplForgotPassword)
			return
		}

		ctx.ServerError("user.ResetPasswd(check existence)", err)
		return
	}

	if !u.IsLocal() && !u.IsOAuth2() {
		ctx.Data["Err_Email"] = true
		ctx.RenderWithErr(ctx.Tr("auth.non_local_account"), tplForgotPassword, nil)
		return
	}

	if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
		ctx.Data["ResendLimited"] = true
		ctx.HTML(http.StatusOK, tplForgotPassword)
		return
	}

	mailer.SendResetPasswordMail(u)

	if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
		log.Error("Set cache(MailResendLimit) fail: %v", err)
	}

	ctx.Data["ResetPwdCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, ctx.Locale.Language())
	ctx.Data["IsResetSent"] = true
	ctx.HTML(http.StatusOK, tplForgotPassword)
}
// ForgotPasswdPost response for forget password request
ForgotPasswdPost response for forget password request
// ForgotPasswdPost response for forget password request
func ForgotPasswdPost(ctx *context.Context) {
	ctx.Data["Title"] = ctx.Tr("auth.forgot_password_title")
	if setting.MailService == nil {
		ctx.NotFound("ForgotPasswdPost", nil)
		return
	}
	ctx.Data["IsResetRequest"] = true
	email := ctx.Query("email")
	ctx.Data["Email"] = email
	u, err := models.GetUserByEmail(email)
	if err != nil {
		if models.IsErrUserNotExist(err) {
			ctx.Data["ResetPwdCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, ctx.Locale.Language())
			ctx.Data["IsResetSent"] = true
			ctx.HTML(http.StatusOK, tplForgotPassword)
			return
		}
		ctx.ServerError("user.ResetPasswd(check existence)", err)
		return
	}
	if !u.IsLocal() && !u.IsOAuth2() {
		ctx.Data["Err_Email"] = true
		ctx.RenderWithErr(ctx.Tr("auth.non_local_account"), tplForgotPassword, nil)
		return
	}
	if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
		ctx.Data["ResendLimited"] = true
		ctx.HTML(http.StatusOK, tplForgotPassword)
		return
	}
	mailer.SendResetPasswordMail(u)
	if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
		log.Error("Set cache(MailResendLimit) fail: %v", err)
	}
	ctx.Data["ResetPwdCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, ctx.Locale.Language())
	ctx.Data["IsResetSent"] = true
	ctx.HTML(http.StatusOK, tplForgotPassword)
}
func ForgotPasswdPost ( ctx * context . Context ) { ctx . Data [ " " ] = ctx . Tr ( " " ) if setting . MailService == nil { ctx . NotFound ( " " , nil ) return } ctx . Data [ " " ] = true email := ctx . Query ( " " ) ctx . Data [ " " ] = email u , err := models . GetUserByEmail ( email ) if err != nil { if models . IsErrUserNotExist ( err ) { ctx . Data [ " " ] = timeutil . MinutesToFriendly ( setting . Service . ResetPwdCodeLives , ctx . Locale . Language ( ) ) ctx . Data [ " " ] = true ctx . HTML ( http . StatusOK , tplForgotPassword ) return } ctx . ServerError ( " " , err ) return } if ! u . IsLocal ( ) && ! u . IsOAuth2 ( ) { ctx . Data [ " " ] = true ctx . RenderWithErr ( ctx . Tr ( " " ) , tplForgotPassword , nil ) return } if ctx . Cache . IsExist ( " " + u . LowerName ) { ctx . Data [ " " ] = true ctx . HTML ( http . StatusOK , tplForgotPassword ) return } mailer . SendResetPasswordMail ( u ) if err = ctx . Cache . Put ( " " + u . LowerName , u . LowerName , 180 ) ; err != nil { log . Error ( " " , err ) } ctx . Data [ " " ] = timeutil . MinutesToFriendly ( setting . Service . ResetPwdCodeLives , ctx . Locale . Language ( ) ) ctx . Data [ " " ] = true ctx . HTML ( http . StatusOK , tplForgotPassword ) }
ForgotPasswdPost response for forget password request
ForgotPasswdPost response for forget password request