feat(07-02): throttle failed logins and pick mail template locale

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-22 14:03:31 +02:00
parent 1311bd6cad
commit 00e6c51abd
7 changed files with 322 additions and 23 deletions

28
classes/mail.go Normal file
View File

@@ -0,0 +1,28 @@
package classes
import (
"context"
"git.golem15.com/golem15/fonoteka/plugins/golem15/user/models"
"git.golem15.com/golem15/summercms/towel"
)
// mailTemplate appends -en for English and leaves every other locale,
// including empty and pl, on the unsuffixed Polish template name.
func mailTemplate(base, locale string) string {
if locale == "en" {
return base + "-en"
}
return base
}
// resolveMailLocale prefers the user's saved locale, then the request locale.
func resolveMailLocale(ctx context.Context, user *models.User) string {
if user != nil && user.PreferredLocale != nil && *user.PreferredLocale != "" {
return *user.PreferredLocale
}
if loc, ok := towel.Locale(ctx); ok {
return loc
}
return ""
}