From de1d14590d671b2d83f3d3844f8e8a4abe8ed618 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Fri, 9 Jun 2023 15:32:55 -0400 Subject: [PATCH] Fix bug for code search if code is disabled (#25173) (#25181) Backport #25173 by @lunny Fix https://github.com/go-gitea/gitea/pull/24189/files#r1224144768 Co-authored-by: Lunny Xiao --- routers/web/web.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routers/web/web.go b/routers/web/web.go index f5037a848e..1e235a3c3c 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -356,7 +356,12 @@ func registerRoutes(m *web.Route) { m.Get("/users", explore.Users) m.Get("/users/sitemap-{idx}.xml", sitemapEnabled, explore.Users) m.Get("/organizations", explore.Organizations) - m.Get("/code", reqUnitAccess(unit.TypeCode, perm.AccessModeRead), explore.Code) + m.Get("/code", func(ctx *context.Context) { + if unit.TypeCode.UnitGlobalDisabled() { + ctx.NotFound(unit.TypeCode.String(), nil) + return + } + }, explore.Code) m.Get("/topics/search", explore.TopicSearch) }, ignExploreSignIn) m.Group("/issues", func() {