mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 04:52:40 +00:00
Fix package cases crash (#313)
This commit is contained in:
parent
a97f54d92f
commit
069a999297
3 changed files with 8 additions and 9 deletions
|
@ -14,7 +14,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var title = cases.Title(language.English)
|
|
||||||
var Locales = NewLocaleStore()
|
var Locales = NewLocaleStore()
|
||||||
|
|
||||||
type LocaleStore struct {
|
type LocaleStore struct {
|
||||||
|
@ -59,7 +58,7 @@ func (store *LocaleStore) loadLocaleFromYAML(localeCode, path string) error {
|
||||||
|
|
||||||
locale := &Locale{
|
locale := &Locale{
|
||||||
Code: localeCode,
|
Code: localeCode,
|
||||||
Name: title.String(name),
|
Name: cases.Title(language.English).String(name),
|
||||||
Messages: make(map[string]string),
|
Messages: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ const (
|
||||||
OpenIDConnect = "openid-connect"
|
OpenIDConnect = "openid-connect"
|
||||||
)
|
)
|
||||||
|
|
||||||
var title = cases.Title(language.English)
|
|
||||||
|
|
||||||
func register(ctx echo.Context) error {
|
func register(ctx echo.Context) error {
|
||||||
disableSignup := getData(ctx, "DisableSignup")
|
disableSignup := getData(ctx, "DisableSignup")
|
||||||
disableForm := getData(ctx, "DisableLoginForm")
|
disableForm := getData(ctx, "DisableLoginForm")
|
||||||
|
@ -188,10 +186,10 @@ func oauthCallback(ctx echo.Context) error {
|
||||||
updateUserProviderInfo(currUser, user.Provider, user)
|
updateUserProviderInfo(currUser, user.Provider, user)
|
||||||
|
|
||||||
if err = currUser.Update(); err != nil {
|
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")
|
return redirect(ctx, "/settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,10 +356,10 @@ func oauth(ctx echo.Context) error {
|
||||||
// Means that the user wants to unlink the account
|
// Means that the user wants to unlink the account
|
||||||
if checkFunc, exists := providerIDCheckMap[provider]; exists && checkFunc() {
|
if checkFunc, exists := providerIDCheckMap[provider]; exists && checkFunc() {
|
||||||
if err := currUser.DeleteProviderID(provider); err != nil {
|
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")
|
return redirect(ctx, "/settings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"github.com/thomiceli/opengist/internal/config"
|
"github.com/thomiceli/opengist/internal/config"
|
||||||
"github.com/thomiceli/opengist/internal/db"
|
"github.com/thomiceli/opengist/internal/db"
|
||||||
"github.com/thomiceli/opengist/internal/i18n"
|
"github.com/thomiceli/opengist/internal/i18n"
|
||||||
|
"golang.org/x/text/cases"
|
||||||
|
"golang.org/x/text/language"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -116,7 +118,7 @@ func loadSettings(ctx echo.Context) error {
|
||||||
|
|
||||||
for key, value := range settings {
|
for key, value := range settings {
|
||||||
s := strings.ReplaceAll(key, "-", " ")
|
s := strings.ReplaceAll(key, "-", " ")
|
||||||
s = title.String(s)
|
s = cases.Title(language.English).String(s)
|
||||||
setData(ctx, strings.ReplaceAll(s, " ", ""), value == "1")
|
setData(ctx, strings.ReplaceAll(s, " ", ""), value == "1")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue