summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-05-20 02:56:45 +0200
committerEarl Warren <contact@earl-warren.org>2024-05-26 18:20:33 +0200
commita649610d6175d1994b838f5672261400df9fdb92 (patch)
tree6a16cf14b370971874cd85b2cc92889cdcfcad1a /services
parent[skip ci] Updated licenses and gitignores (diff)
downloadforgejo-a649610d6175d1994b838f5672261400df9fdb92.tar.xz
forgejo-a649610d6175d1994b838f5672261400df9fdb92.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. (cherry picked from commit edbf74c418061b013a5855f604dd6be6baf34132) Conflicts: templates/repo/create.tmpl templates/repo/migrate/codebase.tmpl templates/repo/migrate/git.tmpl templates/repo/migrate/gitbucket.tmpl templates/repo/migrate/gitea.tmpl templates/repo/migrate/github.tmpl templates/repo/migrate/gitlab.tmpl templates/repo/migrate/gogs.tmpl templates/repo/migrate/onedev.tmpl already in forgejo fc0c5e80da Fix and improve repo visibility checkbox when FORCE_PRIVATE is on (#3786) enforcing FORCE_PRIVATE on repo settings was manually tested with a repository of an unprivileged user after setting FORCE_PRIVATE = true
Diffstat (limited to 'services')
-rw-r--r--services/migrations/gitea_uploader.go2
-rw-r--r--services/repository/repository.go2
-rw-r--r--services/task/task.go2
3 files changed, 3 insertions, 3 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index 1704b2330e..4d54de0b07 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -107,7 +107,7 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate
Description: repo.Description,
OriginalURL: repo.OriginalURL,
GitServiceType: opts.GitServiceType,
- IsPrivate: opts.Private,
+ IsPrivate: opts.Private || setting.Repository.ForcePrivate,
IsMirror: opts.Mirror,
Status: repo_model.RepositoryBeingMigrated,
})
diff --git a/services/repository/repository.go b/services/repository/repository.go
index d28200c0ad..b7aac3cfe0 100644
--- a/services/repository/repository.go
+++ b/services/repository/repository.go
@@ -85,7 +85,7 @@ func PushCreateRepo(ctx context.Context, authUser, owner *user_model.User, repoN
repo, err := CreateRepository(ctx, authUser, owner, CreateRepoOptions{
Name: repoName,
- IsPrivate: setting.Repository.DefaultPushCreatePrivate,
+ IsPrivate: setting.Repository.DefaultPushCreatePrivate || setting.Repository.ForcePrivate,
})
if err != nil {
return nil, err
diff --git a/services/task/task.go b/services/task/task.go
index e15cab7b3c..c90ee91270 100644
--- a/services/task/task.go
+++ b/services/task/task.go
@@ -107,7 +107,7 @@ func CreateMigrateTask(ctx context.Context, doer, u *user_model.User, opts base.
Description: opts.Description,
OriginalURL: opts.OriginalURL,
GitServiceType: opts.GitServiceType,
- IsPrivate: opts.Private,
+ IsPrivate: opts.Private || setting.Repository.ForcePrivate,
IsMirror: opts.Mirror,
Status: repo_model.RepositoryBeingMigrated,
})