diff --git a/router/middleware/session/repo.go b/router/middleware/session/repo.go index 743815998..2822d0095 100644 --- a/router/middleware/session/repo.go +++ b/router/middleware/session/repo.go @@ -83,7 +83,7 @@ func SetPerm() gin.HandlerFunc { return func(c *gin.Context) { user := User(c) repo := Repo(c) - perm := &model.Perm{} + perm := new(model.Perm) switch { case user != nil: @@ -105,6 +105,10 @@ func SetPerm() gin.HandlerFunc { } } + if perm == nil { + perm = new(model.Perm) + } + if user != nil && user.Admin { perm.Pull = true perm.Push = true