Skip to content

Commit 7314a27

Browse files
committed
fix reqExploreSignIn
1 parent ce6eeab commit 7314a27

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

routers/api/v1/api.go

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

357-
func reqExploreSignInAndUsersExploreEnabled() func(ctx *context.APIContext) {
357+
func reqExploreSignIn() func(ctx *context.APIContext) {
358358
return func(ctx *context.APIContext) {
359-
if setting.Service.Explore.DisableUsersPage {
360-
ctx.NotFound()
361-
return
362-
}
363359
if setting.Service.Explore.RequireSigninView && !ctx.IsSigned {
364360
ctx.Error(http.StatusUnauthorized, "reqExploreSignIn", "you must be signed in to search for users")
365361
}
366362
}
367363
}
368364

365+
func reqUsersExploreEnabled() func(ctx *context.APIContext) {
366+
return func(ctx *context.APIContext) {
367+
if setting.Service.Explore.DisableUsersPage {
368+
ctx.NotFound()
369+
}
370+
}
371+
}
372+
369373
func reqBasicOrRevProxyAuth() func(ctx *context.APIContext) {
370374
return func(ctx *context.APIContext) {
371375
if ctx.IsSigned && setting.Service.EnableReverseProxyAuthAPI && ctx.Data["AuthedMethod"].(string) == auth.ReverseProxyMethodName {
@@ -959,16 +963,16 @@ func Routes() *web.Router {
959963

960964
// Users (requires user scope)
961965
m.Group("/users", func() {
962-
m.Get("/search", reqExploreSignInAndUsersExploreEnabled(), user.Search)
966+
m.Get("/search", reqExploreSignIn(), reqUsersExploreEnabled(), user.Search)
963967

964968
m.Group("/{username}", func() {
965-
m.Get("", reqExploreSignInAndUsersExploreEnabled(), user.GetInfo)
969+
m.Get("", reqExploreSignIn(), user.GetInfo)
966970

967971
if setting.Service.EnableUserHeatmap {
968972
m.Get("/heatmap", user.GetUserHeatmapData)
969973
}
970974

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

0 commit comments

Comments
 (0)