Filter repositories route by work if defined
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2022-09-16 17:26:02 +02:00
parent 0ab96472e4
commit f615d0b8d8

View File

@ -55,7 +55,19 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
return return
} }
c.JSON(http.StatusOK, repositories) if work, ok := c.Get("work"); ok {
var res []*Repository
for _, r := range repositories {
if r.IdWork == work.(*Work).Id {
res = append(res, r)
}
}
c.JSON(http.StatusOK, res)
} else {
c.JSON(http.StatusOK, repositories)
}
}) })
router.POST("/repositories", func(c *gin.Context) { router.POST("/repositories", func(c *gin.Context) {
var u *User var u *User