summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-03-14 22:13:54 -0400
committerEthan Koenig <ethantkoenig@gmail.com>2017-03-15 14:09:44 -0400
commit17f403fbcd9bdffc8f9901119482fa200ca572f7 (patch)
tree99757f14c111f2caecd55f7f7379c9c6f81161fd /modules
parent780cb692d64edfadea6f79fbbad2ef033cdbe796 (diff)
downloadgitea-17f403fbcd9bdffc8f9901119482fa200ca572f7.tar.gz
gitea-17f403fbcd9bdffc8f9901119482fa200ca572f7.zip
Fix nil-dereference bug
Diffstat (limited to 'modules')
-rw-r--r--modules/context/repo.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 9e37ae3fbf..895640a823 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -219,7 +219,11 @@ func RepoAssignment(args ...bool) macaron.Handler {
if ctx.IsSigned && ctx.User.IsAdmin {
ctx.Repo.AccessMode = models.AccessModeOwner
} else {
- mode, err := models.AccessLevel(ctx.User.ID, repo)
+ var userID int64
+ if ctx.User != nil {
+ userID = ctx.User.ID
+ }
+ mode, err := models.AccessLevel(userID, repo)
if err != nil {
ctx.Handle(500, "AccessLevel", err)
return