From 854178bc1e0fd3c2f7badf2b5703d6486555fd1d Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 18 Mar 2022 09:57:07 +0000 Subject: [PATCH] Do not send activation email if manual confirm is set (#19119) Backport #19119 If the mailer is configured then even if Manual confirm is set an activation email is still being sent because `handleUserCreated` is not checking for this case. Fix #17263 Signed-off-by: Andrew Thornton Co-authored-by: Lunny Xiao --- options/locale/locale_en-US.ini | 1 + routers/web/auth/auth.go | 6 ++++++ templates/user/auth/activate.tmpl | 2 ++ 3 files changed, 9 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2fbf7e79bc7fd..3024051f6e35b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -281,6 +281,7 @@ register_helper_msg = Already have an account? Sign in now! social_register_helper_msg = Already have an account? Link it now! disable_register_prompt = Registration is disabled. Please contact your site administrator. disable_register_mail = Email confirmation for registration is disabled. +manual_activation_only = Contact your site administrator to complete activation. remember_me = Remember this Device forgot_password_title= Forgot Password forgot_password = Forgot password? diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index bec26ec30fe9e..ad92cc2c3d740 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -621,6 +621,12 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth. // Send confirmation email if !u.IsActive && u.ID > 1 { + if setting.Service.RegisterManualConfirm { + ctx.Data["ManualActivationOnly"] = true + ctx.HTML(http.StatusOK, TplActivate) + return + } + mailer.SendActivateAccountMail(ctx.Locale, u) ctx.Data["IsSendRegisterMail"] = true diff --git a/templates/user/auth/activate.tmpl b/templates/user/auth/activate.tmpl index 8d75c1d92eae8..65dfd6b6a6f76 100644 --- a/templates/user/auth/activate.tmpl +++ b/templates/user/auth/activate.tmpl @@ -32,6 +32,8 @@

{{.i18n.Tr "auth.confirmation_mail_sent_prompt" (.Email|Escape) .ActiveCodeLives | Str2html}}

{{else if .IsActivateFailed}}

{{.i18n.Tr "auth.invalid_code"}}

+ {{else if .ManualActivationOnly}} +

{{.i18n.Tr "auth.manual_activation_only"}}

{{else}}

{{.i18n.Tr "auth.has_unconfirmed_mail" (.SignedUser.Name|Escape) (.SignedUser.Email|Escape) | Str2html}}