mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-24 03:21:49 +01:00
Allow admin users to set a repositoires visibility to public, even if FORCE_PRIVATE is to true (#6541) (#6572)
Signed-off-by: Matthias Beckert <beckert.matthias@googlemail.com>
This commit is contained in:
parent
66fa092cc8
commit
5348573fdf
2 changed files with 6 additions and 2 deletions
|
@ -95,8 +95,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
visibilityChanged := repo.IsPrivate != form.Private
|
visibilityChanged := repo.IsPrivate != form.Private
|
||||||
// when ForcePrivate enabled, you could change public repo to private, but could not change private to public
|
// when ForcePrivate enabled, you could change public repo to private, but only admin users can change private to public
|
||||||
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private {
|
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private && !ctx.User.IsAdmin {
|
||||||
ctx.ServerError("Force Private enabled", errors.New("cannot change private repository to public"))
|
ctx.ServerError("Force Private enabled", errors.New("cannot change private repository to public"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,11 @@
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label>{{.i18n.Tr "repo.visibility"}}</label>
|
<label>{{.i18n.Tr "repo.visibility"}}</label>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
|
{{if .IsAdmin}}
|
||||||
|
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}>
|
||||||
|
{{else}}
|
||||||
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}{{if and $.ForcePrivate .Repository.IsPrivate}} readonly{{end}}>
|
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}{{if and $.ForcePrivate .Repository.IsPrivate}} readonly{{end}}>
|
||||||
|
{{end}}
|
||||||
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visibility_fork_helper"}}</span>{{end}}</label>
|
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visibility_fork_helper"}}</span>{{end}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue