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>
This commit is contained in:
zeripath 2019-01-28 20:26:55 +00:00 committed by GitHub
parent d3a334d99a
commit 29799537a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {