1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-30 08:06:52 +02:00

Copied MustAdmin into MustTeamAdmin for now

This commit is contained in:
Thomas Boerger 2016-08-01 23:58:13 +02:00
parent 4d43195479
commit 31cead0eb4
No known key found for this signature in database
GPG Key ID: 5A388F55283960B6
2 changed files with 22 additions and 1 deletions

View 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()
}
}
}

View File

@ -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")
{