Skip to content
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

If repo.projects unit is disabled, it's still shown in user profile page #25934

Closed
pmandalka opened this issue Jul 17, 2023 · 1 comment · Fixed by #26182
Closed

If repo.projects unit is disabled, it's still shown in user profile page #25934

pmandalka opened this issue Jul 17, 2023 · 1 comment · Fixed by #26182
Labels
topic/ui Change the appearance of the Gitea UI type/bug

Comments

@pmandalka
Copy link

pmandalka commented Jul 17, 2023

Description

I'm using the DISABLE_REPO_UNITS to disable the projects unit. In most places, the project links are removed but in the user profile, the link still exists.

image

Clicking on that, leads to a 404 page

Screenshots

image

Gitea Version

1.20

Can you reproduce the bug on the Gitea demo site?

No

Operating System

Docker on Debian

Browser Version

Chrome 114

@pmandalka pmandalka added type/bug topic/ui Change the appearance of the Gitea UI labels Jul 17, 2023
@Zettat123
Copy link
Contributor

When repo.projects is disabled, clicking links of user-level projects and org-level projects leads to 404 page.
Since DISABLED_REPO_UNITS is used to control repo-level units, I think we need to fix the project unit checks (including reqUnitAccess(unit.TypeProjects, ...) and repo.MustEnableProjects) for user/org level projects.

gitea/routers/web/web.go

Lines 833 to 864 in 24b49bc

m.Group("/projects", func() {
m.Group("", func() {
m.Get("", org.Projects)
m.Get("/{id}", org.ViewProject)
}, reqUnitAccess(unit.TypeProjects, perm.AccessModeRead))
m.Group("", func() { //nolint:dupl
m.Get("/new", org.RenderNewProject)
m.Post("/new", web.Bind(forms.CreateProjectForm{}), org.NewProjectPost)
m.Group("/{id}", func() {
m.Post("", web.Bind(forms.EditProjectBoardForm{}), org.AddBoardToProjectPost)
m.Post("/delete", org.DeleteProject)
m.Get("/edit", org.RenderEditProject)
m.Post("/edit", web.Bind(forms.CreateProjectForm{}), org.EditProjectPost)
m.Post("/{action:open|close}", org.ChangeProjectStatus)
m.Group("/{boardID}", func() {
m.Put("", web.Bind(forms.EditProjectBoardForm{}), org.EditProjectBoard)
m.Delete("", org.DeleteProjectBoard)
m.Post("/default", org.SetDefaultProjectBoard)
m.Post("/unsetdefault", org.UnsetDefaultProjectBoard)
m.Post("/move", org.MoveIssues)
})
})
}, reqSignIn, reqUnitAccess(unit.TypeProjects, perm.AccessModeWrite), func(ctx *context.Context) {
if ctx.ContextUser.IsIndividual() && ctx.ContextUser.ID != ctx.Doer.ID {
ctx.NotFound("NewProject", nil)
return
}
})
}, repo.MustEnableProjects)

lunny pushed a commit that referenced this issue Jul 29, 2023
Fix #25934

Add `ignoreGlobal` parameter to `reqUnitAccess` and only check global
disabled units when `ignoreGlobal` is true. So the org-level projects
and user-level projects won't be affected by global disabled
`repo.projects` unit.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Jul 29, 2023
Fix go-gitea#25934

Add `ignoreGlobal` parameter to `reqUnitAccess` and only check global
disabled units when `ignoreGlobal` is true. So the org-level projects
and user-level projects won't be affected by global disabled
`repo.projects` unit.
silverwind pushed a commit that referenced this issue Jul 29, 2023
Backport #26182 by @Zettat123

Fix #25934

Add `ignoreGlobal` parameter to `reqUnitAccess` and only check global
disabled units when `ignoreGlobal` is true. So the org-level projects
and user-level projects won't be affected by global disabled
`repo.projects` unit.

Co-authored-by: Zettat123 <zettat123@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants