소스 검색

Fix 500 when getting user as unauthenticated user (#8662)

When doing GET /api/v1/users/{user} as an unauthenticated user,
gitea throws a 500 because it's trying to dereference elements
from the context user. It wants to do this to see whether to
show the primary email and will do that if the logged in user
is admin or the user in question. However, if ctx.User is nil,
go gets really unhappy.
tags/v1.9.5
Monty Taylor 4 년 전
부모
커밋
66ceee08dc
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1
    1
      routers/api/v1/user/user.go

+ 1
- 1
routers/api/v1/user/user.go 파일 보기

@@ -104,7 +104,7 @@ func GetInfo(ctx *context.APIContext) {
return
}

ctx.JSON(200, convert.ToUser(u, ctx.IsSigned, ctx.User.ID == u.ID || ctx.User.IsAdmin))
ctx.JSON(200, convert.ToUser(u, ctx.IsSigned, ctx.User != nil && (ctx.User.ID == u.ID || ctx.User.IsAdmin)))
}

// GetAuthenticatedUser get current user's information

Loading…
취소
저장