From 1e64c27918d6ec0293d0e2fbcb68c5fb9d53db17 Mon Sep 17 00:00:00 2001 From: Settel Date: Tue, 1 Mar 2022 12:40:09 +0100 Subject: [PATCH] feat: admin interface: player's auth code --- server/src/application/getGameInfo.go | 9 +++++++++ server/src/game/struct.go | 1 + 2 files changed, 10 insertions(+) diff --git a/server/src/application/getGameInfo.go b/server/src/application/getGameInfo.go index a290722..86708f6 100644 --- a/server/src/application/getGameInfo.go +++ b/server/src/application/getGameInfo.go @@ -23,6 +23,15 @@ func (app *Application) GetGameInfo(usr *user.User, w http.ResponseWriter, r *ht } gameInfo := gm.GetGameInfo() + for i, _ := range gameInfo.Players { + if playerUser, err := app.GetUserById(gameInfo.Players[i].Id); err != nil { + w.WriteHeader(http.StatusInternalServerError) + fmt.Fprintf(w, "internal server error") + return + } else { + gameInfo.Players[i].AuthCode = playerUser.GetAuthCode() + } + } w.Header().Add("Content-Type", "application/json") jsonString, _ := json.Marshal(gameInfo) diff --git a/server/src/game/struct.go b/server/src/game/struct.go index 0b972ab..27b991f 100644 --- a/server/src/game/struct.go +++ b/server/src/game/struct.go @@ -87,6 +87,7 @@ type PlayerInfoJson struct { IsPlaying bool `json:"isPlaying"` IsIdle bool `json:"isIdle"` NumberOfQuotes int `json:"numQuotes"` + AuthCode string `json:"authcode"` } type GameInfoJson struct {