Show error instead of 500 HTTP error if authenticate fails via external SMTP

Close #27043
This commit is contained in:
hyg 2023-09-12 23:34:28 +08:00
parent 684ab403aa
commit 814ca03be8
1 changed files with 5 additions and 0 deletions

View File

@ -211,6 +211,11 @@ func SignInPost(ctx *context.Context) {
log.Info("Failed authentication attempt for %s from %s: %v", form.UserName, ctx.RemoteAddr(), err)
ctx.Data["Title"] = ctx.Tr("auth.prohibit_login")
ctx.HTML(http.StatusOK, "user/auth/prohibit_login")
} else if errors.As(err, &textprotoErr) {
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), tplSignIn, &form)
log.Info("Failed authentication attempt for %s from %s (code: %d, msg: %s)", form.UserName, ctx.RemoteAddr(),
textprotoErr.Code, textprotoErr.Msg,
)
} else if user_model.IsErrUserInactive(err) {
if setting.Service.RegisterEmailConfirm {
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")