diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-05-20 08:56:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-20 00:56:45 +0000 |
commit | edbf74c418061b013a5855f604dd6be6baf34132 (patch) | |
tree | 0c8fa83ec5f2eec37669d6eb75274a79de8f7e78 /routers/api | |
parent | 82a0c36332824b8ab41efdf6503e86170ce92f08 (diff) | |
download | gitea-edbf74c418061b013a5855f604dd6be6baf34132.tar.gz gitea-edbf74c418061b013a5855f604dd6be6baf34132.zip |
Fix "force private" logic (#31012)
When creating a repo, the "FORCE_PRIVATE" config option should be
respected, `readonly` doesn't work for checkbox, so it should use
`disabled` attribute.
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/migrate.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go index f246b08c0a..14c8c01f4e 100644 --- a/routers/api/v1/repo/migrate.go +++ b/routers/api/v1/repo/migrate.go @@ -175,7 +175,7 @@ func Migrate(ctx *context.APIContext) { Description: opts.Description, OriginalURL: form.CloneAddr, GitServiceType: gitServiceType, - IsPrivate: opts.Private, + IsPrivate: opts.Private || setting.Repository.ForcePrivate, IsMirror: opts.Mirror, Status: repo_model.RepositoryBeingMigrated, }) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index e759142938..594f2d86f6 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -252,7 +252,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre Gitignores: opt.Gitignores, License: opt.License, Readme: opt.Readme, - IsPrivate: opt.Private, + IsPrivate: opt.Private || setting.Repository.ForcePrivate, AutoInit: opt.AutoInit, DefaultBranch: opt.DefaultBranch, TrustModel: repo_model.ToTrustModel(opt.TrustModel), @@ -364,7 +364,7 @@ func Generate(ctx *context.APIContext) { Name: form.Name, DefaultBranch: form.DefaultBranch, Description: form.Description, - Private: form.Private, + Private: form.Private || setting.Repository.ForcePrivate, GitContent: form.GitContent, Topics: form.Topics, GitHooks: form.GitHooks, |