diff options
| author | nsfisis <54318333+nsfisis@users.noreply.github.com> | 2026-02-21 09:35:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-21 09:35:03 +0900 |
| commit | aa25d66376f30c590c697a2c7eb981a24e1057bb (patch) | |
| tree | cd6dc50573a90bb2625df981b8c9305c63f156c0 /backend/gen/api/handler_wrapper_gen.go | |
| parent | 00354d392a0bcddaac71fee7b6aae721e5747f59 (diff) | |
| parent | 277c9726f0f39d1db83624a8b62a77ac19c2ac0a (diff) | |
| download | phperkaigi-2026-albatross-aa25d66376f30c590c697a2c7eb981a24e1057bb.tar.gz phperkaigi-2026-albatross-aa25d66376f30c590c697a2c7eb981a24e1057bb.tar.zst phperkaigi-2026-albatross-aa25d66376f30c590c697a2c7eb981a24e1057bb.zip | |
Merge pull request #6 from nsfisis/claude/allow-viewing-without-login-zODtV
Allow unauthenticated users to view games and watch matches
Diffstat (limited to 'backend/gen/api/handler_wrapper_gen.go')
| -rw-r--r-- | backend/gen/api/handler_wrapper_gen.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/backend/gen/api/handler_wrapper_gen.go b/backend/gen/api/handler_wrapper_gen.go index e3e56c1..88f55c6 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 -}} |
