Wire the user API session loop to the JWT blacklist and a pre-password throttle gate so a logged-out token cannot be fetched again. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
729 B
Go
29 lines
729 B
Go
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 ""
|
|
}
|