mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-17 03:45:13 +00:00
Copied MustAdmin into MustTeamAdmin for now
This commit is contained in:
parent
4d43195479
commit
31cead0eb4
2 changed files with 22 additions and 1 deletions
21
router/middleware/session/team.go
Normal file
21
router/middleware/session/team.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func MustTeamAdmin() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
user := User(c)
|
||||
switch {
|
||||
case user == nil:
|
||||
c.String(401, "User not authorized")
|
||||
c.Abort()
|
||||
case user.Admin == false:
|
||||
c.String(413, "User not authorized")
|
||||
c.Abort()
|
||||
default:
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||
|
||||
teams := e.Group("/api/teams")
|
||||
{
|
||||
// TODO: Restrict access
|
||||
user.Use(session.MustTeamAdmin())
|
||||
|
||||
team := teams.Group("/:team")
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue