aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-01-28 20:26:55 +0000
committerGitHub <noreply@github.com>2019-01-28 20:26:55 +0000
commit29799537a76fce9f2582b95ae3426f5f0c96eb44 (patch)
tree14a89090d7cfcbf48638adc618861e191124c4f2
parentd3a334d99ad5a95001c29468fc0b7326e24b080d (diff)
downloadgitea-29799537a76fce9f2582b95ae3426f5f0c96eb44.tar.gz
gitea-29799537a76fce9f2582b95ae3426f5f0c96eb44.zip
API: Fix null pointer in attempt to Sudo if not logged in (#5872) (#5884)
Backport of #5872 to v1.7 Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r--routers/api/v1/api.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index dcc77969f1..d06e3ce7a5 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -85,7 +85,7 @@ func sudo() macaron.Handler {
}
if len(sudo) > 0 {
- if ctx.User.IsAdmin {
+ if ctx.IsSigned && ctx.User.IsAdmin {
user, err := models.GetUserByName(sudo)
if err != nil {
if models.IsErrUserNotExist(err) {