-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Require at least one unit to be enabled #24189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5bf9752
8d5c8aa
b5cf290
dc362c6
b84f8f6
3dd3125
a7b2f85
a009d7e
dafab3c
21774f7
cd22bf0
5460744
b082965
a3f5819
c70f297
2dddf93
832aebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,27 @@ func registerRoutes(m *web.Route) { | |
} | ||
} | ||
|
||
reqUnitAccess := func(unitType unit.Type, accessMode perm.AccessMode) func(ctx *context.Context) { | ||
return func(ctx *context.Context) { | ||
if unitType.UnitGlobalDisabled() { | ||
ctx.NotFound(unitType.String(), nil) | ||
return | ||
} | ||
|
||
if ctx.ContextUser == nil { | ||
ctx.NotFound(unitType.String(), nil) | ||
return | ||
} | ||
|
||
if ctx.ContextUser.IsOrganization() { | ||
if ctx.Org.Organization.UnitPermission(ctx, ctx.Doer, unitType) < accessMode { | ||
ctx.NotFound(unitType.String(), nil) | ||
return | ||
} | ||
} | ||
} | ||
} | ||
|
||
addWebhookAddRoutes := func() { | ||
m.Get("/{type}/new", repo.WebhooksNew) | ||
m.Post("/gitea/new", web.Bind(forms.NewWebhookForm{}), repo.GiteaHooksNewPost) | ||
|
@@ -334,7 +355,7 @@ 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", explore.Code) | ||
m.Get("/code", reqUnitAccess(unit.TypeCode, perm.AccessModeRead), explore.Code) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lunny I can no longer access Isn't this "unit access" thing something that applies only to repos, not global? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it should be a bug. #25173 should fix it. Now every unit could be disabled globally. The bug is it should not check ContextUser because this router maybe allowed to visit anonymously. |
||
m.Get("/topics/search", explore.TopicSearch) | ||
}, ignExploreSignIn) | ||
m.Group("/issues", func() { | ||
|
@@ -649,21 +670,6 @@ func registerRoutes(m *web.Route) { | |
} | ||
} | ||
|
||
reqUnitAccess := func(unitType unit.Type, accessMode perm.AccessMode) func(ctx *context.Context) { | ||
return func(ctx *context.Context) { | ||
if ctx.ContextUser == nil { | ||
ctx.NotFound(unitType.String(), nil) | ||
return | ||
} | ||
if ctx.ContextUser.IsOrganization() { | ||
if ctx.Org.Organization.UnitPermission(ctx, ctx.Doer, unitType) < accessMode { | ||
ctx.NotFound(unitType.String(), nil) | ||
return | ||
} | ||
} | ||
} | ||
} | ||
|
||
// ***** START: Organization ***** | ||
m.Group("/org", func() { | ||
m.Group("/{org}", func() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.