This commit is contained in:
Evan Goode 2025-07-19 18:30:04 -04:00
parent 04d949667b
commit 79428c5286
6 changed files with 11 additions and 9 deletions

2
api.go
View File

@ -120,7 +120,7 @@ func (app *App) APIRequestToMaybeUser(c echo.Context) (mo.Option[User], error) {
bearerExp := regexp.MustCompile("^Bearer (.*)$") bearerExp := regexp.MustCompile("^Bearer (.*)$")
tokenMatch := bearerExp.FindStringSubmatch(authorizationHeader) tokenMatch := bearerExp.FindStringSubmatch(authorizationHeader)
if tokenMatch == nil || len(tokenMatch) < 2 { if len(tokenMatch) < 2 {
return mo.None[User](), NewUserErrorWithCode(http.StatusUnauthorized, "Malformed Authorization header") return mo.None[User](), NewUserErrorWithCode(http.StatusUnauthorized, "Malformed Authorization header")
} }
token := tokenMatch[1] token := tokenMatch[1]

View File

@ -1335,7 +1335,8 @@ func frontChallenge(app *App, action string) func(c echo.Context) error {
var playerName string var playerName string
var userUUID *string var userUUID *string
if action == ChallengeActionRegister { switch action {
case ChallengeActionRegister:
if useIDToken { if useIDToken {
provider, _, claims, err := app.getIDTokenCookie(&c) provider, _, claims, err := app.getIDTokenCookie(&c)
if err != nil { if err != nil {
@ -1358,7 +1359,7 @@ func frontChallenge(app *App, action string) func(c echo.Context) error {
} else { } else {
playerName = c.QueryParam("playerName") playerName = c.QueryParam("playerName")
} }
} else if action == ChallengeActionCreatePlayer { case ChallengeActionCreatePlayer:
playerName = c.QueryParam("playerName") playerName = c.QueryParam("playerName")
userUUID = Ptr(c.QueryParam("userUuid")) userUUID = Ptr(c.QueryParam("userUuid"))
} }

View File

@ -439,7 +439,7 @@ func setup(config *Config) *App {
locales := map[language.Tag]*gotext.Locale{} locales := map[language.Tag]*gotext.Locale{}
localeTags := make([]language.Tag, 0) localeTags := make([]language.Tag, 0)
localesPath := path.Join(config.DataDirectory, "locales") localesPath := path.Join(config.DataDirectory, "locales")
langPaths, err := filepath.Glob(path.Join(localesPath, "*")) langPaths := Unwrap(filepath.Glob(path.Join(localesPath, "*")))
defaultLang := "en-US" // TODO config option? defaultLang := "en-US" // TODO config option?
var defaultLocale *gotext.Locale var defaultLocale *gotext.Locale
for _, lang_path := range langPaths { for _, lang_path := range langPaths {

View File

@ -402,7 +402,7 @@ func (app *App) GetClient(accessToken string, stalePolicy StaleTokenPolicy) *Cli
} }
var client Client var client Client
result := app.DB.Preload("User").Preload("Player").First(&client, "uuid = ?", claims.RegisteredClaims.Subject) result := app.DB.Preload("User").Preload("Player").First(&client, "uuid = ?", claims.Subject)
if result.Error != nil { if result.Error != nil {
return nil return nil
} }

View File

@ -30,9 +30,10 @@ func (app *App) getTexture(
if textureReader != nil || textureURL != nil { if textureReader != nil || textureURL != nil {
allowed := false allowed := false
if textureType == TextureTypeSkin { switch textureType {
case TextureTypeSkin:
allowed = app.Config.AllowSkins allowed = app.Config.AllowSkins
} else if textureType == TextureTypeCape { case TextureTypeCape:
allowed = app.Config.AllowCapes allowed = app.Config.AllowCapes
} }
if !allowed && !callerIsAdmin { if !allowed && !callerIsAdmin {

View File

@ -34,7 +34,7 @@ func withBearerAuthentication(app *App, f func(c echo.Context, user *User, playe
} }
accessTokenMatch := bearerExp.FindStringSubmatch(authorizationHeader) accessTokenMatch := bearerExp.FindStringSubmatch(authorizationHeader)
if accessTokenMatch == nil || len(accessTokenMatch) < 2 { if len(accessTokenMatch) < 2 {
return &YggdrasilError{Code: http.StatusUnauthorized} return &YggdrasilError{Code: http.StatusUnauthorized}
} }
accessToken := accessTokenMatch[1] accessToken := accessTokenMatch[1]
@ -114,7 +114,7 @@ func getServicesProfile(app *App, player *Player) (ServicesProfile, error) {
return nil return nil
} }
var skins []ServicesProfileSkin = []ServicesProfileSkin{} skins := []ServicesProfileSkin{}
if skin := getServicesProfileSkin(); skin != nil { if skin := getServicesProfileSkin(); skin != nil {
skins = []ServicesProfileSkin{*skin} skins = []ServicesProfileSkin{*skin}
} }