mirror of
https://github.com/thomiceli/opengist
synced 2024-11-08 12:55:50 +01:00
Fix package cases crash (#313)
This commit is contained in:
parent
a97f54d92f
commit
069a999297
@ -14,7 +14,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var title = cases.Title(language.English)
|
||||
var Locales = NewLocaleStore()
|
||||
|
||||
type LocaleStore struct {
|
||||
@ -59,7 +58,7 @@ func (store *LocaleStore) loadLocaleFromYAML(localeCode, path string) error {
|
||||
|
||||
locale := &Locale{
|
||||
Code: localeCode,
|
||||
Name: title.String(name),
|
||||
Name: cases.Title(language.English).String(name),
|
||||
Messages: make(map[string]string),
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,6 @@ const (
|
||||
OpenIDConnect = "openid-connect"
|
||||
)
|
||||
|
||||
var title = cases.Title(language.English)
|
||||
|
||||
func register(ctx echo.Context) error {
|
||||
disableSignup := getData(ctx, "DisableSignup")
|
||||
disableForm := getData(ctx, "DisableLoginForm")
|
||||
@ -188,10 +186,10 @@ func oauthCallback(ctx echo.Context) error {
|
||||
updateUserProviderInfo(currUser, user.Provider, user)
|
||||
|
||||
if err = currUser.Update(); err != nil {
|
||||
return errorRes(500, "Cannot update user "+title.String(user.Provider)+" id", err)
|
||||
return errorRes(500, "Cannot update user "+cases.Title(language.English).String(user.Provider)+" id", err)
|
||||
}
|
||||
|
||||
addFlash(ctx, tr(ctx, "flash.auth.account-linked-oauth", title.String(user.Provider)), "success")
|
||||
addFlash(ctx, tr(ctx, "flash.auth.account-linked-oauth", cases.Title(language.English).String(user.Provider)), "success")
|
||||
return redirect(ctx, "/settings")
|
||||
}
|
||||
|
||||
@ -358,10 +356,10 @@ func oauth(ctx echo.Context) error {
|
||||
// Means that the user wants to unlink the account
|
||||
if checkFunc, exists := providerIDCheckMap[provider]; exists && checkFunc() {
|
||||
if err := currUser.DeleteProviderID(provider); err != nil {
|
||||
return errorRes(500, "Cannot unlink account from "+title.String(provider), err)
|
||||
return errorRes(500, "Cannot unlink account from "+cases.Title(language.English).String(provider), err)
|
||||
}
|
||||
|
||||
addFlash(ctx, tr(ctx, "flash.auth.account-unlinked-oauth", title.String(provider)), "success")
|
||||
addFlash(ctx, tr(ctx, "flash.auth.account-unlinked-oauth", cases.Title(language.English).String(provider)), "success")
|
||||
return redirect(ctx, "/settings")
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import (
|
||||
"github.com/thomiceli/opengist/internal/config"
|
||||
"github.com/thomiceli/opengist/internal/db"
|
||||
"github.com/thomiceli/opengist/internal/i18n"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@ -116,7 +118,7 @@ func loadSettings(ctx echo.Context) error {
|
||||
|
||||
for key, value := range settings {
|
||||
s := strings.ReplaceAll(key, "-", " ")
|
||||
s = title.String(s)
|
||||
s = cases.Title(language.English).String(s)
|
||||
setData(ctx, strings.ReplaceAll(s, " ", ""), value == "1")
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user