From e6df2259abdeb75545f53a5ca4c247491b5c3d7f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 13 Mar 2017 02:41:04 -0400 Subject: [PATCH] explore: panic if search without login (#3088) --- routers/home.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routers/home.go b/routers/home.go index 63a564903..3c1aa6d59 100644 --- a/routers/home.go +++ b/routers/home.go @@ -75,9 +75,13 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { } count = opts.Counter(opts.Private) } else { + var ctxUserID int64 + if ctx.IsSigned { + ctxUserID = ctx.User.ID + } repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ Keyword: keyword, - UserID: ctx.User.ID, + UserID: ctxUserID, OrderBy: opts.OrderBy, Private: opts.Private, Page: page,