From 4af93cae1ca54ad7c9bc7eb4b56c010f55c4c72d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Feb 2026 17:53:55 +0000 Subject: 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 --- backend/gen/api/handler_wrapper_gen.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'backend/gen/api/handler_wrapper_gen.go') diff --git a/backend/gen/api/handler_wrapper_gen.go b/backend/gen/api/handler_wrapper_gen.go index e3e56c1..982e191 100644 --- a/backend/gen/api/handler_wrapper_gen.go +++ b/backend/gen/api/handler_wrapper_gen.go @@ -61,16 +61,26 @@ func main() { } slices.Sort(methods) + loginOptionalMethods := map[string]bool{ + "GetGames": true, + "GetGame": true, + "GetGameWatchLatestStates": true, + "GetGameWatchRanking": true, + "GetTournament": true, + } + type TemplateParameter struct { Name string RequiresLogin bool + LoginOptional bool RequiresAdminRole bool } templateParameters := make([]TemplateParameter, len(methods)) for i, method := range methods { templateParameters[i] = TemplateParameter{ Name: method, - RequiresLogin: method != "PostLogin", + RequiresLogin: method != "PostLogin" && !loginOptionalMethods[method], + LoginOptional: loginOptionalMethods[method], RequiresAdminRole: strings.Contains(method, "Admin"), } } @@ -144,6 +154,9 @@ func NewHandler(queries db.Querier, txm db.TxManager, hub GameHubInterface, auth } {{ end -}} return h.impl.{{ .Name }}(ctx, request, user) + {{ else if .LoginOptional -}} + user, _ := GetUserFromContext(ctx) + return h.impl.{{ .Name }}(ctx, request, user) {{ else -}} return h.impl.{{ .Name }}(ctx, request) {{ end -}} -- cgit v1.3.1