aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
authorZettat123 <zettat123@gmail.com>2024-10-22 13:09:19 +0800
committerGitHub <noreply@github.com>2024-10-22 13:09:19 +0800
commit9206fbb55fd28f21720072fce6a36cc22277934c (patch)
treef8b99ae96e1446423194ca03032300248b0dd76f /routers/api/v1
parent3d6ccbac3f20c485ab95a29d280c9371e558bfac (diff)
downloadgitea-9206fbb55fd28f21720072fce6a36cc22277934c.tar.gz
gitea-9206fbb55fd28f21720072fce6a36cc22277934c.zip
Add `DISABLE_ORGANIZATIONS_PAGE` and `DISABLE_CODE_PAGE` settings for explore pages and fix an issue related to user search (#32288)
These settings can allow users to only display the repositories explore page. Thanks to yp05327 and wxiaoguang ! --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/api.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 883e694e44..bfc601c835 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -356,12 +356,20 @@ func reqToken() func(ctx *context.APIContext) {
func reqExploreSignIn() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) {
- if setting.Service.Explore.RequireSigninView && !ctx.IsSigned {
+ if (setting.Service.RequireSignInView || setting.Service.Explore.RequireSigninView) && !ctx.IsSigned {
ctx.Error(http.StatusUnauthorized, "reqExploreSignIn", "you must be signed in to search for users")
}
}
}
+func reqUsersExploreEnabled() func(ctx *context.APIContext) {
+ return func(ctx *context.APIContext) {
+ if setting.Service.Explore.DisableUsersPage {
+ ctx.NotFound()
+ }
+ }
+}
+
func reqBasicOrRevProxyAuth() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) {
if ctx.IsSigned && setting.Service.EnableReverseProxyAuthAPI && ctx.Data["AuthedMethod"].(string) == auth.ReverseProxyMethodName {
@@ -955,7 +963,7 @@ func Routes() *web.Router {
// Users (requires user scope)
m.Group("/users", func() {
- m.Get("/search", reqExploreSignIn(), user.Search)
+ m.Get("/search", reqExploreSignIn(), reqUsersExploreEnabled(), user.Search)
m.Group("/{username}", func() {
m.Get("", reqExploreSignIn(), user.GetInfo)