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:
parent
4d43195479
commit
31cead0eb4
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")
|
teams := e.Group("/api/teams")
|
||||||
{
|
{
|
||||||
// TODO: Restrict access
|
user.Use(session.MustTeamAdmin())
|
||||||
|
|
||||||
team := teams.Group("/:team")
|
team := teams.Group("/:team")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user