From 63ba6af242c51f104399060f9b7fb000baed4364 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 14 Sep 2017 15:20:20 -0700 Subject: [PATCH] fix nil perm issue --- router/middleware/session/repo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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