ADD: added new auth middleware and changed the roles value ind the jwt token to a array

This commit is contained in:
hwinkel
2025-11-23 22:55:04 +01:00
parent 139a99d96e
commit 3a6c3a86e3
9 changed files with 84 additions and 30 deletions

View File

@@ -54,9 +54,11 @@ func main() {
api.POST("/tournaments/:id/join", tournament.JoinTournament)
api.PUT("/tournaments/:id", tournament.UpdateTournament)
api.GET("/players", func(c *gin.Context) {
player.GetPlayers(c, db.GetDB())
})
// api.GET("/players", func(c *gin.Context) {
// player.GetPlayers(c, db.GetDB())
// })
api.GET("/players", auth.AuthorizeJWT("admin"), func(c *gin.Context) { player.GetPlayers(c, db.GetDB()) })
api.GET("/players/:id", func(c *gin.Context) {
player.GetPlayer(c, db.GetDB(), c.Param("id"))
})
@@ -72,7 +74,7 @@ func main() {
// c.JSON(http.StatusOK, gin.H{"message": "Player deleted successfully"})
})
api.GET("/teams", func(c *gin.Context) {
})
port := os.Getenv("PORT")