From bf47f70c3b4a70c55680ad6d0436593242e60d9e Mon Sep 17 00:00:00 2001
From: zeripath <art27@cantab.net>
Date: Mon, 28 Jan 2019 14:13:59 +0000
Subject: [PATCH] API: Fix null pointer in attempt to Sudo if not logged in
 (#5872)

Signed-off-by: Andrew Thornton <art27@cantab.net>
---
 routers/api/v1/api.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 2787d01a0..d8f78550c 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) {