-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
type/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.
Milestone
Description
Scenario
- On our instance we have
MAX_CREATION_LIMIT = 0to prevent random new users from spamming our instance - There is an org which has a few members, which is being used for a collaborative project. These members should only be able to create repos inside this org, but not under their user account.
- Users have been put into a team
Devwhich hasCreate repositoriesenabled
Problem
- On the repo create page, the submit button
Create Repositoryis disabled in caseCanCreateRepo == false:gitea/templates/repo/create.tmpl
Line 212 in 5c91d79
<button class="ui primary button{{if not .CanCreateRepo}} disabled{{end}}"> CanCreateRepochecks whether the user already has too many personal repos:Lines 240 to 251 in 5c91d79
func (u *User) CanCreateRepo() bool { if u.IsAdmin { return true } if u.MaxRepoCreation <= -1 { if setting.Repository.MaxCreationLimit <= -1 { return true } return u.NumRepos < setting.Repository.MaxCreationLimit } return u.NumRepos < u.MaxRepoCreation } - But the submit button will be disabled for all available repo owners; Personal and also Orgs!
- This means the UI will not allow users to create org repos even though they have the
Create repositoriespermission in their org! - EDIT: This problem also affects repos which are created from migrations (this however is a backend issue!)
Solutions
- This is only a UI bug, the backend validation works as expected (I have tested this by removing the previously mentioned disable check from the template to force the button to be always enabled)
- The
CanCreateRepovalue should only influence creation of a personal repo - Repo limit of the org is only checked after the form is submitted, this would be a good quick-fix for this issue (removing the disabled button check and the error banner from the template)
- For a long term solution we could hide the personal user account in the owners list the same way orgs are hidden when their limit is reached. This would make the disabled submit button and the banner completely obsolete, as the user is forced to select an owner that is allowed to have more repos created
Note that I was not able to reproduce the issue on the demo instance, because there is no repo count limit and also it seems like you can't create orgs there..
Screenshots
Trying to create a new repo testrepo45 under testorg organization, note the banner telling me there is a limit:

Repo create works anyway when enabling the submit button by hand:

Gitea Version
v1.21.9
thetek42
Metadata
Metadata
Assignees
Labels
type/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.
