diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-04-01 01:31:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 19:31:53 +0200 |
commit | 420851ca1ff5c97cc31930f022daaff6f484793b (patch) | |
tree | 8fbf05e426c30db2ad2ea706d53cf2c60d4989c3 /routers/web/web.go | |
parent | c88547ce71a554091930e129c20776daf6da35ac (diff) | |
download | gitea-420851ca1ff5c97cc31930f022daaff6f484793b.tar.gz gitea-420851ca1ff5c97cc31930f022daaff6f484793b.zip |
Fix global packages enabled avaiable (#19276)
Fix #19275
Diffstat (limited to 'routers/web/web.go')
-rw-r--r-- | routers/web/web.go | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/routers/web/web.go b/routers/web/web.go index 5ff8174be4..3bdedab854 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -473,10 +473,12 @@ func RegisterRoutes(m *web.Route) { m.Post("/delete", admin.DeleteRepo) }) - m.Group("/packages", func() { - m.Get("", admin.Packages) - m.Post("/delete", admin.DeletePackageVersion) - }) + if setting.Packages.Enabled { + m.Group("/packages", func() { + m.Get("", admin.Packages) + m.Post("/delete", admin.DeletePackageVersion) + }) + } m.Group("/hooks", func() { m.Get("", admin.DefaultOrSystemWebhooks) @@ -670,21 +672,23 @@ func RegisterRoutes(m *web.Route) { }, reqSignIn) m.Group("/{username}/-", func() { - m.Group("/packages", func() { - m.Get("", user.ListPackages) - m.Group("/{type}/{name}", func() { - m.Get("", user.RedirectToLastVersion) - m.Get("/versions", user.ListPackageVersions) - m.Group("/{version}", func() { - m.Get("", user.ViewPackageVersion) - m.Get("/files/{fileid}", user.DownloadPackageFile) - m.Group("/settings", func() { - m.Get("", user.PackageSettings) - m.Post("", bindIgnErr(forms.PackageSettingForm{}), user.PackageSettingsPost) - }, reqPackageAccess(perm.AccessModeWrite)) + if setting.Packages.Enabled { + m.Group("/packages", func() { + m.Get("", user.ListPackages) + m.Group("/{type}/{name}", func() { + m.Get("", user.RedirectToLastVersion) + m.Get("/versions", user.ListPackageVersions) + m.Group("/{version}", func() { + m.Get("", user.ViewPackageVersion) + m.Get("/files/{fileid}", user.DownloadPackageFile) + m.Group("/settings", func() { + m.Get("", user.PackageSettings) + m.Post("", bindIgnErr(forms.PackageSettingForm{}), user.PackageSettingsPost) + }, reqPackageAccess(perm.AccessModeWrite)) + }) }) - }) - }, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead)) + }, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead)) + } }, context_service.UserAssignmentWeb()) // ***** Release Attachment Download without Signin @@ -973,7 +977,9 @@ func RegisterRoutes(m *web.Route) { m.Get("/milestones", reqRepoIssuesOrPullsReader, repo.Milestones) }, context.RepoRef()) - m.Get("/packages", repo.Packages) + if setting.Packages.Enabled { + m.Get("/packages", repo.Packages) + } m.Group("/projects", func() { m.Get("", repo.Projects) |