This commit is contained in:
Evan Goode 2025-07-19 18:30:04 -04:00
parent 3097c11b31
commit a87ecaf6a4
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 (.*)$")
tokenMatch := bearerExp.FindStringSubmatch(authorizationHeader)
if tokenMatch == nil || len(tokenMatch) < 2 {
if len(tokenMatch) < 2 {
return mo.None[User](), NewUserErrorWithCode(http.StatusUnauthorized, "Malformed Authorization header")
}
token := tokenMatch[1]

View File

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

View File

@ -439,7 +439,7 @@ func setup(config *Config) *App {
locales := map[language.Tag]*gotext.Locale{}
localeTags := make([]language.Tag, 0)
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?
var defaultLocale *gotext.Locale
for _, lang_path := range langPaths {

View File

@ -402,7 +402,7 @@ func (app *App) GetClient(accessToken string, stalePolicy StaleTokenPolicy) *Cli
}
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 {
return nil
}

View File

@ -30,9 +30,10 @@ func (app *App) getTexture(
if textureReader != nil || textureURL != nil {
allowed := false
if textureType == TextureTypeSkin {
switch textureType {
case TextureTypeSkin:
allowed = app.Config.AllowSkins
} else if textureType == TextureTypeCape {
case TextureTypeCape:
allowed = app.Config.AllowCapes
}
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)
if accessTokenMatch == nil || len(accessTokenMatch) < 2 {
if len(accessTokenMatch) < 2 {
return &YggdrasilError{Code: http.StatusUnauthorized}
}
accessToken := accessTokenMatch[1]
@ -114,7 +114,7 @@ func getServicesProfile(app *App, player *Player) (ServicesProfile, error) {
return nil
}
var skins []ServicesProfileSkin = []ServicesProfileSkin{}
skins := []ServicesProfileSkin{}
if skin := getServicesProfileSkin(); skin != nil {
skins = []ServicesProfileSkin{*skin}
}