admin: Can view team 0/public my.json

This commit is contained in:
nemunaire 2024-03-28 18:24:43 +01:00
parent 298d09f346
commit 9172f36be7
1 changed files with 10 additions and 2 deletions

View File

@ -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."})