From 9172f36be7fa7bb16e29dbefa0e0b635f03d0d88 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 28 Mar 2024 18:24:43 +0100 Subject: [PATCH] admin: Can view team 0/public my.json --- admin/api/team.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/api/team.go b/admin/api/team.go index d43e2898..e62f5da9 100644 --- a/admin/api/team.go +++ b/admin/api/team.go @@ -90,7 +90,11 @@ func declareTeamsRoutes(router *gin.RouterGroup) { apiTeamsPublicRoutes := router.Group("/teams/:tid") apiTeamsPublicRoutes.Use(TeamPublicHandler) apiTeamsPublicRoutes.GET("/my.json", func(c *gin.Context) { - tfile, err := fic.MyJSONTeam(c.MustGet("team").(*fic.Team), true) + var team *fic.Team + if t, ok := c.Get("team"); ok && t != nil { + team = t.(*fic.Team) + } + tfile, err := fic.MyJSONTeam(team, true) if err != nil { log.Println("Unable to get MyJSONTeam:", err.Error()) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs during team JSON generation."}) @@ -100,7 +104,11 @@ func declareTeamsRoutes(router *gin.RouterGroup) { c.JSON(http.StatusOK, tfile) }) apiTeamsPublicRoutes.GET("/wait.json", func(c *gin.Context) { - tfile, err := fic.MyJSONTeam(c.MustGet("team").(*fic.Team), false) + var team *fic.Team + if t, ok := c.Get("team"); ok && t != nil { + team = t.(*fic.Team) + } + tfile, err := fic.MyJSONTeam(team, false) if err != nil { log.Println("Unable to get MyJSONTeam:", err.Error()) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs during team JSON generation."})