aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-03-20 21:04:51 +0000
committerGitHub <noreply@github.com>2022-03-20 22:04:51 +0100
commit49c5fc565c326a7b8be190e5109fffefc2cf5ec1 (patch)
tree720c797913ad74d31e58bb7942390e2bbca6e08d
parent83a2f79d5d236bd1328de1c4465bdecd20aa5bb5 (diff)
downloadgitea-49c5fc565c326a7b8be190e5109fffefc2cf5ec1.tar.gz
gitea-49c5fc565c326a7b8be190e5109fffefc2cf5ec1.zip
Fix NPE `/repos/issues/search` when not signed in (#19154)
- Don't panic when on `/repos/issues/search?{created,assigned,mentioned,review_requested}=true` when client didn't pass any authentication. - Resolves #19115
-rw-r--r--routers/api/v1/repo/issue.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 9e550c4c47..c96eb34855 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -245,18 +245,23 @@ func SearchIssues(ctx *context.APIContext) {
UpdatedAfterUnix: since,
}
+ ctxUserID := int64(0)
+ if ctx.IsSigned {
+ ctxUserID = ctx.User.ID
+ }
+
// Filter for: Created by User, Assigned to User, Mentioning User, Review of User Requested
if ctx.FormBool("created") {
- issuesOpt.PosterID = ctx.User.ID
+ issuesOpt.PosterID = ctxUserID
}
if ctx.FormBool("assigned") {
- issuesOpt.AssigneeID = ctx.User.ID
+ issuesOpt.AssigneeID = ctxUserID
}
if ctx.FormBool("mentioned") {
- issuesOpt.MentionedID = ctx.User.ID
+ issuesOpt.MentionedID = ctxUserID
}
if ctx.FormBool("review_requested") {
- issuesOpt.ReviewRequestedID = ctx.User.ID
+ issuesOpt.ReviewRequestedID = ctxUserID
}
if issues, err = models.Issues(issuesOpt); err != nil {