Skip to content

Commit 814ca03

Browse files
committed
Show error instead of 500 HTTP error if authenticate fails via external SMTP
Close #27043
1 parent 684ab40 commit 814ca03

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

routers/web/auth/auth.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ func SignInPost(ctx *context.Context) {
211211
log.Info("Failed authentication attempt for %s from %s: %v", form.UserName, ctx.RemoteAddr(), err)
212212
ctx.Data["Title"] = ctx.Tr("auth.prohibit_login")
213213
ctx.HTML(http.StatusOK, "user/auth/prohibit_login")
214+
} else if errors.As(err, &textprotoErr) {
215+
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), tplSignIn, &form)
216+
log.Info("Failed authentication attempt for %s from %s (code: %d, msg: %s)", form.UserName, ctx.RemoteAddr(),
217+
textprotoErr.Code, textprotoErr.Msg,
218+
)
214219
} else if user_model.IsErrUserInactive(err) {
215220
if setting.Service.RegisterEmailConfirm {
216221
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")

0 commit comments

Comments
 (0)