aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handler.go
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-02-20 17:53:55 +0000
committerClaude <noreply@anthropic.com>2026-02-20 17:53:55 +0000
commit4af93cae1ca54ad7c9bc7eb4b56c010f55c4c72d (patch)
tree804f0aee031469aad98a15cf8307cc9f0794c5bc /backend/api/handler.go
parent00354d392a0bcddaac71fee7b6aae721e5747f59 (diff)
downloadphperkaigi-2026-albatross-4af93cae1ca54ad7c9bc7eb4b56c010f55c4c72d.tar.gz
phperkaigi-2026-albatross-4af93cae1ca54ad7c9bc7eb4b56c010f55c4c72d.tar.zst
phperkaigi-2026-albatross-4af93cae1ca54ad7c9bc7eb4b56c010f55c4c72d.zip
feat: allow viewing/spectating games without login
Make watch, ranking, game list, and tournament endpoints accessible without authentication. Unauthenticated users can browse games and spectate from the index page, while play/submit/preview still require login. https://claude.ai/code/session_019j9tNcnLsLz15e1qtbmeqe
Diffstat (limited to 'backend/api/handler.go')
-rw-r--r--backend/api/handler.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/backend/api/handler.go b/backend/api/handler.go
index 57ae973..dcebfa1 100644
--- a/backend/api/handler.go
+++ b/backend/api/handler.go
@@ -218,7 +218,7 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use
}
return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
- if !row.IsPublic && !user.IsAdmin {
+ if !row.IsPublic && (user == nil || !user.IsAdmin) {
return GetGame404JSONResponse{
Message: "Game not found",
}, nil
@@ -318,7 +318,7 @@ func (h *Handler) GetGameWatchLatestStates(ctx context.Context, request GetGameW
Status: status,
}
- if row.UserID == user.UserID && !user.IsAdmin {
+ if user != nil && row.UserID == user.UserID && !user.IsAdmin {
return GetGameWatchLatestStates403JSONResponse{
Message: "You are one of the main players of this game",
}, nil