Skip to content

Commit

Permalink
add permission check for GenerateRepository (go-gitea#15946)
Browse files Browse the repository at this point in the history
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
  • Loading branch information
3 people authored and AbdulrhmnGhanem committed Aug 10, 2021
1 parent 8611f9e commit 9a40256
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions services/repository/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (

// GenerateRepository generates a repository from a template
func GenerateRepository(doer, owner *models.User, templateRepo *models.Repository, opts models.GenerateRepoOptions) (_ *models.Repository, err error) {
if !doer.IsAdmin && !owner.CanCreateRepo() {
return nil, models.ErrReachLimitOfRepo{
Limit: owner.MaxRepoCreation,
}
}

var generateRepo *models.Repository
if err = models.WithTx(func(ctx models.DBContext) error {
generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
Expand Down

0 comments on commit 9a40256

Please sign in to comment.