Add configuration option for default permission to create Organizations (#1686)

tokarchuk/v1.17
Lauris BH 8 years ago committed by Kim "BKC" Carlbäcker
parent a85c5ab9ff
commit 51d0becb42
  1. 3
      conf/app.ini
  2. 1
      integrations/mysql.ini
  3. 1
      integrations/pgsql.ini
  4. 1
      integrations/sqlite.ini
  5. 2
      models/user.go
  6. 1
      modules/auth/user_form.go
  7. 2
      modules/setting/setting.go
  8. 3
      options/locale/locale_en-US.ini
  9. 4
      public/css/index.css
  10. 4
      public/less/_admin.less
  11. 2
      routers/install.go
  12. 2
      templates/admin/config.tmpl
  13. 6
      templates/install.tmpl

3
conf/app.ini vendored

@ -240,6 +240,9 @@ ENABLE_CAPTCHA = true
; Default value for KeepEmailPrivate ; Default value for KeepEmailPrivate
; New user will get the value of this setting copied into their profile ; New user will get the value of this setting copied into their profile
DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_KEEP_EMAIL_PRIVATE = false
; Default value for AllowCreateOrganization
; New user will have rights set to create organizations depending on this setting
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
; Default value for the domain part of the user's email address in the git log ; Default value for the domain part of the user's email address in the git log
; if he has set KeepEmailPrivate true. The user's email replaced with a ; if he has set KeepEmailPrivate true. The user's email replaced with a
; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS. ; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.

@ -32,6 +32,7 @@ DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
NO_REPLY_ADDRESS = noreply.example.org NO_REPLY_ADDRESS = noreply.example.org
[picture] [picture]

@ -32,6 +32,7 @@ DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
NO_REPLY_ADDRESS = noreply.example.org NO_REPLY_ADDRESS = noreply.example.org
[picture] [picture]

@ -32,6 +32,7 @@ DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
NO_REPLY_ADDRESS = noreply.example.org NO_REPLY_ADDRESS = noreply.example.org
[picture] [picture]

@ -706,7 +706,7 @@ func CreateUser(u *User) (err error) {
return err return err
} }
u.EncodePasswd() u.EncodePasswd()
u.AllowCreateOrganization = true u.AllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization
u.MaxRepoCreation = -1 u.MaxRepoCreation = -1
sess := x.NewSession() sess := x.NewSession()

@ -45,6 +45,7 @@ type InstallForm struct {
EnableCaptcha bool EnableCaptcha bool
RequireSignInView bool RequireSignInView bool
DefaultKeepEmailPrivate bool DefaultKeepEmailPrivate bool
DefaultAllowCreateOrganization bool
NoReplyAddress string NoReplyAddress string
AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"` AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`

@ -972,6 +972,7 @@ var Service struct {
EnableReverseProxyAutoRegister bool EnableReverseProxyAutoRegister bool
EnableCaptcha bool EnableCaptcha bool
DefaultKeepEmailPrivate bool DefaultKeepEmailPrivate bool
DefaultAllowCreateOrganization bool
NoReplyAddress string NoReplyAddress string
// OpenID settings // OpenID settings
@ -992,6 +993,7 @@ func newService() {
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool() Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool() Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool()
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool() Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org") Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
sec = Cfg.Section("openid") sec = Cfg.Section("openid")

@ -132,6 +132,8 @@ install_success = Welcome! We're glad that you chose Gitea, have fun and take ca
invalid_log_root_path = Log root path is invalid: %v invalid_log_root_path = Log root path is invalid: %v
default_keep_email_private = Default Value for Keep Email Private default_keep_email_private = Default Value for Keep Email Private
default_keep_email_private_popup = This is the default value for the visibility of the user's email address. If set to true the email address of all new users will be hidden until the user changes his setting. default_keep_email_private_popup = This is the default value for the visibility of the user's email address. If set to true the email address of all new users will be hidden until the user changes his setting.
default_allow_create_organization = Default permission value for new users to create Organizations
default_allow_create_organization_popup = This is default permission value that will be assigned for new users. If set to true new users will be allowed to create Organizations.
no_reply_address = No-reply Address no_reply_address = No-reply Address
no_reply_address_helper = Domain for the user's email address in git logs if he keeps his email address private. E.g. user 'joe' and 'noreply.example.org' will be 'joe@noreply.example.org' no_reply_address_helper = Domain for the user's email address in git logs if he keeps his email address private. E.g. user 'joe' and 'noreply.example.org' will be 'joe@noreply.example.org'
@ -1260,6 +1262,7 @@ config.enable_captcha = Enable Captcha
config.active_code_lives = Active Code Lives config.active_code_lives = Active Code Lives
config.reset_password_code_lives = Reset Password Code Lives config.reset_password_code_lives = Reset Password Code Lives
config.default_keep_email_private = Default Value for Keep Email Private config.default_keep_email_private = Default Value for Keep Email Private
config.default_allow_create_organization = Default permission to create Organizations
config.no_reply_address = No-reply Address config.no_reply_address = No-reply Address
config.webhook_config = Webhook Configuration config.webhook_config = Webhook Configuration

@ -2938,12 +2938,12 @@ footer .ui.language .menu {
margin: 0; margin: 0;
} }
.admin dl.admin-dl-horizontal dd { .admin dl.admin-dl-horizontal dd {
margin-left: 240px; margin-left: 275px;
} }
.admin dl.admin-dl-horizontal dt { .admin dl.admin-dl-horizontal dt {
font-weight: bolder; font-weight: bolder;
float: left; float: left;
width: 250px; width: 285px;
clear: left; clear: left;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

@ -45,12 +45,12 @@
margin: 0; margin: 0;
dd { dd {
margin-left: 240px; margin-left: 275px;
} }
dt { dt {
font-weight: bolder; font-weight: bolder;
float: left; float: left;
width: 250px; width: 285px;
clear: left; clear: left;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

@ -112,6 +112,7 @@ func Install(ctx *context.Context) {
form.EnableCaptcha = setting.Service.EnableCaptcha form.EnableCaptcha = setting.Service.EnableCaptcha
form.RequireSignInView = setting.Service.RequireSignInView form.RequireSignInView = setting.Service.RequireSignInView
form.DefaultKeepEmailPrivate = setting.Service.DefaultKeepEmailPrivate form.DefaultKeepEmailPrivate = setting.Service.DefaultKeepEmailPrivate
form.DefaultAllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization
form.NoReplyAddress = setting.Service.NoReplyAddress form.NoReplyAddress = setting.Service.NoReplyAddress
auth.AssignForm(form, ctx.Data) auth.AssignForm(form, ctx.Data)
@ -295,6 +296,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha)) cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha))
cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView)) cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView))
cfg.Section("service").Key("DEFAULT_KEEP_EMAIL_PRIVATE").SetValue(com.ToStr(form.DefaultKeepEmailPrivate)) cfg.Section("service").Key("DEFAULT_KEEP_EMAIL_PRIVATE").SetValue(com.ToStr(form.DefaultKeepEmailPrivate))
cfg.Section("service").Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").SetValue(com.ToStr(form.DefaultAllowCreateOrganization))
cfg.Section("service").Key("NO_REPLY_ADDRESS").SetValue(com.ToStr(form.NoReplyAddress)) cfg.Section("service").Key("NO_REPLY_ADDRESS").SetValue(com.ToStr(form.NoReplyAddress))
cfg.Section("").Key("RUN_MODE").SetValue("prod") cfg.Section("").Key("RUN_MODE").SetValue("prod")

@ -128,6 +128,8 @@
<dd><i class="fa fa{{if .Service.EnableCaptcha}}-check{{end}}-square-o"></i></dd> <dd><i class="fa fa{{if .Service.EnableCaptcha}}-check{{end}}-square-o"></i></dd>
<dt>{{.i18n.Tr "admin.config.default_keep_email_private"}}</dt> <dt>{{.i18n.Tr "admin.config.default_keep_email_private"}}</dt>
<dd><i class="fa fa{{if .Service.DefaultKeepEmailPrivate}}-check{{end}}-square-o"></i></dd> <dd><i class="fa fa{{if .Service.DefaultKeepEmailPrivate}}-check{{end}}-square-o"></i></dd>
<dt>{{.i18n.Tr "admin.config.default_allow_create_organization"}}</dt>
<dd><i class="fa fa{{if .Service.DefaultAllowCreateOrganization}}-check{{end}}-square-o"></i></dd>
<dt>{{.i18n.Tr "admin.config.no_reply_address"}}</dt> <dt>{{.i18n.Tr "admin.config.no_reply_address"}}</dt>
<dd>{{if .Service.NoReplyAddress}}{{.Service.NoReplyAddress}}{{else}}-{{end}}</dd> <dd>{{if .Service.NoReplyAddress}}{{.Service.NoReplyAddress}}{{else}}-{{end}}</dd>
<div class="ui divider"></div> <div class="ui divider"></div>

@ -212,6 +212,12 @@
<input name="default_keep_email_private" type="checkbox" {{if .default_keep_email_private}}checked{{end}}> <input name="default_keep_email_private" type="checkbox" {{if .default_keep_email_private}}checked{{end}}>
</div> </div>
</div> </div>
<div class="inline field">
<div class="ui checkbox">
<label class="poping up" data-content="{{.i18n.Tr "install.default_allow_create_organization_popup"}}"><strong>{{.i18n.Tr "install.default_allow_create_organization"}}</strong></label>
<input name="default_allow_create_organization" type="checkbox" {{if .default_allow_create_organization}}checked{{end}}>
</div>
</div>
<div class="inline field"> <div class="inline field">
<label for="no_reply_address">{{.i18n.Tr "install.no_reply_address"}}</label> <label for="no_reply_address">{{.i18n.Tr "install.no_reply_address"}}</label>
<input id="_no_reply_address" name="no_reply_address" value="{{.no_reply_address}}"> <input id="_no_reply_address" name="no_reply_address" value="{{.no_reply_address}}">

Loading…
Cancel
Save