From c28a35271a47a3989bc46b13257e63c806b41746 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Mon, 22 Mar 2021 21:04:38 -0500 Subject: [PATCH] Add better errors for disabled account recovery Signed-off-by: jolheiser --- options/locale/locale_en-US.ini | 4 ++-- routers/user/auth.go | 1 + templates/user/auth/forgot_passwd.tmpl | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index e679e1e874979..d0a748492020a 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -299,7 +299,8 @@ openid_connect_desc = The chosen OpenID URI is unknown. Associate it with a new openid_register_title = Create new account openid_register_desc = The chosen OpenID URI is unknown. Associate it with a new account here. openid_signin_desc = Enter your OpenID URI. For example: https://anne.me, bob.openid.org.cn or gnusocial.net/carry. -disable_forgot_password_mail = Account recovery is disabled. Please contact your site administrator. +disable_forgot_password_mail = Account recovery is disabled because no email is set up. Please contact your site administrator. +disable_forgot_password_mail_admin = Account recovery is only available when email is set up. Please set up email to enable account recovery. email_domain_blacklisted = You cannot register with your email address. authorize_application = Authorize Application authorize_redirect_notice = You will be redirected to %s if you authorize this application. @@ -308,7 +309,6 @@ authorize_application_description = If you grant the access, it will be able to authorize_title = Authorize "%s" to access your account? authorization_failed = Authorization failed authorization_failed_desc = The authorization failed because we detected an invalid request. Please contact the maintainer of the app you've tried to authorize. -disable_forgot_password_mail = Account recovery is disabled. Please contact your site administrator. sspi_auth_failed = SSPI authentication failed password_pwned = The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password. password_pwned_err = Could not complete request to HaveIBeenPwned diff --git a/routers/user/auth.go b/routers/user/auth.go index 37181c68e7a24..244b5bada535f 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -1347,6 +1347,7 @@ func ForgotPasswd(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.forgot_password_title") if setting.MailService == nil { + log.Warn(ctx.Tr("auth.disable_forgot_password_mail_admin")) ctx.Data["IsResetDisable"] = true ctx.HTML(200, tplForgotPassword) return diff --git a/templates/user/auth/forgot_passwd.tmpl b/templates/user/auth/forgot_passwd.tmpl index 241deeed4a798..2ff7acb97de43 100644 --- a/templates/user/auth/forgot_passwd.tmpl +++ b/templates/user/auth/forgot_passwd.tmpl @@ -22,7 +22,13 @@ {{else if .IsResetDisable}} -

{{.i18n.Tr "auth.disable_forgot_password_mail"}}

+

+ {{if $.IsAdmin}} + {{.i18n.Tr "auth.disable_forgot_password_mail_admin"}} + {{else}} + {{.i18n.Tr "auth.disable_forgot_password_mail"}} + {{end}} +

{{else if .ResendLimited}}

{{.i18n.Tr "auth.resent_limit_prompt"}}

{{end}}