diff options
author | a1012112796 <1012112796@qq.com> | 2021-05-28 00:08:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 12:08:46 -0400 |
commit | b27a9d43a5c0b473c30b6137e0309d103793dcad (patch) | |
tree | 84bb0917afc85f35683050524e4f6b006c106f45 /services | |
parent | c61b460038d461ae4df722b28fd0b9871393ea84 (diff) | |
download | gitea-b27a9d43a5c0b473c30b6137e0309d103793dcad.tar.gz gitea-b27a9d43a5c0b473c30b6137e0309d103793dcad.zip |
add permission check for ``GenerateRepository`` (#15946)
Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services')
-rw-r--r-- | services/repository/generate.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/services/repository/generate.go b/services/repository/generate.go index 067f8f61d0..43cbb45a41 100644 --- a/services/repository/generate.go +++ b/services/repository/generate.go @@ -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) |