mirror of
https://github.com/go-gitea/gitea
synced 2024-11-17 15:31:06 +01:00
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>
This commit is contained in:
parent
c61b460038
commit
b27a9d43a5
1 changed files with 6 additions and 0 deletions
|
@ -13,6 +13,12 @@ import (
|
||||||
|
|
||||||
// GenerateRepository generates a repository from a template
|
// GenerateRepository generates a repository from a template
|
||||||
func GenerateRepository(doer, owner *models.User, templateRepo *models.Repository, opts models.GenerateRepoOptions) (_ *models.Repository, err error) {
|
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
|
var generateRepo *models.Repository
|
||||||
if err = models.WithTx(func(ctx models.DBContext) error {
|
if err = models.WithTx(func(ctx models.DBContext) error {
|
||||||
generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
|
generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
|
||||||
|
|
Loading…
Reference in a new issue