summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-23 05:56:05 +0800
committerzeripath <art27@cantab.net>2019-02-22 21:56:05 +0000
commit4a2fbbeb101555129ab83f972c41936113f1f6c2 (patch)
treec49f69b37865c6a4cad19dd81141173b8fa680ea /routers
parent134e55510eda8c3c6d61da18ee97e3243c6e3bc2 (diff)
downloadgitea-4a2fbbeb101555129ab83f972c41936113f1f6c2.tar.gz
gitea-4a2fbbeb101555129ab83f972c41936113f1f6c2.zip
fix bug user could change private repository to public when force private enabled. (#6156)
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/setting.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 5b5eaeb288..809aab27aa 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -6,6 +6,7 @@
package repo
import (
+ "errors"
"strings"
"time"
@@ -36,6 +37,7 @@ const (
func Settings(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsOptions"] = true
+ ctx.Data["ForcePrivate"] = setting.Repository.ForcePrivate
ctx.HTML(200, tplSettingsOptions)
}
@@ -94,6 +96,12 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
}
visibilityChanged := repo.IsPrivate != form.Private
+ // when ForcePrivate enabled, you could change public repo to private, but could not change private to public
+ if visibilityChanged && setting.Repository.ForcePrivate && !form.Private {
+ ctx.ServerError("Force Private enabled", errors.New("cannot change private repository to public"))
+ return
+ }
+
repo.IsPrivate = form.Private
if err := models.UpdateRepository(repo, visibilityChanged); err != nil {
ctx.ServerError("UpdateRepository", err)