1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Refactor HTTP Client and LocalizedError packages

This commit is contained in:
Frédéric Guillot 2023-10-21 19:50:29 -07:00
parent 120aabfbce
commit 14e25ab9fe
104 changed files with 1277 additions and 10672 deletions

View file

@ -12,6 +12,7 @@ import (
"miniflux.app/v2/internal/http/request"
"miniflux.app/v2/internal/http/response/html"
"miniflux.app/v2/internal/http/route"
"miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/ui/form"
"miniflux.app/v2/internal/ui/session"
"miniflux.app/v2/internal/ui/view"
@ -23,16 +24,17 @@ func (h *handler) checkLogin(w http.ResponseWriter, r *http.Request) {
authForm := form.NewAuthForm(r)
view := view.New(h.tpl, r, sess)
view.Set("errorMessage", "error.bad_credentials")
view.Set("errorMessage", locale.NewLocalizedError("error.bad_credentials").Translate(request.UserLanguage(r)))
view.Set("form", authForm)
if err := authForm.Validate(); err != nil {
if validationErr := authForm.Validate(); validationErr != nil {
translatedErrorMessage := validationErr.Translate(request.UserLanguage(r))
slog.Warn("Validation error during login check",
slog.Bool("authentication_failed", true),
slog.String("client_ip", clientIP),
slog.String("user_agent", r.UserAgent()),
slog.String("username", authForm.Username),
slog.Any("error", err),
slog.Any("error", translatedErrorMessage),
)
html.OK(w, r, view.Render("login"))
return