Skip to content

Commit b88875b

Browse files
committed
fix api middleware
1 parent 0b04828 commit b88875b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

routers/api/v1/api.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,12 @@ func reqToken() func(ctx *context.APIContext) {
354354
}
355355
}
356356

357-
func reqExploreSignIn() func(ctx *context.APIContext) {
357+
func reqExploreSignInAndUsersExploreEnabled() func(ctx *context.APIContext) {
358358
return func(ctx *context.APIContext) {
359+
if setting.Service.Explore.DisableUsersPage {
360+
ctx.NotFound()
361+
return
362+
}
359363
if setting.Service.Explore.RequireSigninView && !ctx.IsSigned {
360364
ctx.Error(http.StatusUnauthorized, "reqExploreSignIn", "you must be signed in to search for users")
361365
}
@@ -955,16 +959,16 @@ func Routes() *web.Router {
955959

956960
// Users (requires user scope)
957961
m.Group("/users", func() {
958-
m.Get("/search", reqExploreSignIn(), user.Search)
962+
m.Get("/search", reqExploreSignInAndUsersExploreEnabled(), user.Search)
959963

960964
m.Group("/{username}", func() {
961-
m.Get("", reqExploreSignIn(), user.GetInfo)
965+
m.Get("", reqExploreSignInAndUsersExploreEnabled(), user.GetInfo)
962966

963967
if setting.Service.EnableUserHeatmap {
964968
m.Get("/heatmap", user.GetUserHeatmapData)
965969
}
966970

967-
m.Get("/repos", tokenRequiresScopes(auth_model.AccessTokenScopeCategoryRepository), reqExploreSignIn(), user.ListUserRepos)
971+
m.Get("/repos", tokenRequiresScopes(auth_model.AccessTokenScopeCategoryRepository), reqExploreSignInAndUsersExploreEnabled(), user.ListUserRepos)
968972
m.Group("/tokens", func() {
969973
m.Combo("").Get(user.ListAccessTokens).
970974
Post(bind(api.CreateAccessTokenOption{}), reqToken(), user.CreateAccessToken)

0 commit comments

Comments
 (0)