mirror of
https://github.com/go-gitea/gitea
synced 2024-11-24 15:42:46 +01:00
issue-2768: added new option allow_only_external_registration (#3910)
This commit is contained in:
parent
e74055878f
commit
1546458f7d
8 changed files with 20 additions and 2 deletions
|
@ -288,6 +288,8 @@ RESET_PASSWD_CODE_LIVE_MINUTES = 180
|
||||||
REGISTER_EMAIL_CONFIRM = false
|
REGISTER_EMAIL_CONFIRM = false
|
||||||
; Disallow registration, only allow admins to create accounts.
|
; Disallow registration, only allow admins to create accounts.
|
||||||
DISABLE_REGISTRATION = false
|
DISABLE_REGISTRATION = false
|
||||||
|
; Allow registration only using third part services, it works only when DISABLE_REGISTRATION is false
|
||||||
|
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
|
||||||
; User must sign in to view anything.
|
; User must sign in to view anything.
|
||||||
REQUIRE_SIGNIN_VIEW = false
|
REQUIRE_SIGNIN_VIEW = false
|
||||||
; Mail notification
|
; Mail notification
|
||||||
|
|
|
@ -44,6 +44,7 @@ type InstallForm struct {
|
||||||
EnableOpenIDSignIn bool
|
EnableOpenIDSignIn bool
|
||||||
EnableOpenIDSignUp bool
|
EnableOpenIDSignUp bool
|
||||||
DisableRegistration bool
|
DisableRegistration bool
|
||||||
|
AllowOnlyExternalRegistration bool
|
||||||
EnableCaptcha bool
|
EnableCaptcha bool
|
||||||
RequireSignInView bool
|
RequireSignInView bool
|
||||||
DefaultKeepEmailPrivate bool
|
DefaultKeepEmailPrivate bool
|
||||||
|
|
|
@ -1143,6 +1143,7 @@ var Service struct {
|
||||||
ResetPwdCodeLives int
|
ResetPwdCodeLives int
|
||||||
RegisterEmailConfirm bool
|
RegisterEmailConfirm bool
|
||||||
DisableRegistration bool
|
DisableRegistration bool
|
||||||
|
AllowOnlyExternalRegistration bool
|
||||||
ShowRegistrationButton bool
|
ShowRegistrationButton bool
|
||||||
RequireSignInView bool
|
RequireSignInView bool
|
||||||
EnableNotifyMail bool
|
EnableNotifyMail bool
|
||||||
|
@ -1168,7 +1169,8 @@ func newService() {
|
||||||
Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
|
Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
|
||||||
Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
|
Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
|
||||||
Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
|
Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
|
||||||
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration)
|
Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
|
||||||
|
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
|
||||||
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
|
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
|
||||||
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
|
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
|
||||||
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
|
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
|
||||||
|
|
|
@ -117,6 +117,7 @@ federated_avatar_lookup = Enable Federated Avatars
|
||||||
federated_avatar_lookup_popup = Enable federated avatar lookup using Libravatar.
|
federated_avatar_lookup_popup = Enable federated avatar lookup using Libravatar.
|
||||||
disable_registration = Disable Self-Registration
|
disable_registration = Disable Self-Registration
|
||||||
disable_registration_popup = Disable user self-registration. Only administrators will be able to create new user accounts.
|
disable_registration_popup = Disable user self-registration. Only administrators will be able to create new user accounts.
|
||||||
|
allow_only_external_registration_popup=Enable the registration only through external services.
|
||||||
openid_signin = Enable OpenID Sign-In
|
openid_signin = Enable OpenID Sign-In
|
||||||
openid_signin_popup = Enable user sign-in via OpenID.
|
openid_signin_popup = Enable user sign-in via OpenID.
|
||||||
openid_signup = Enable OpenID Self-Registration
|
openid_signup = Enable OpenID Self-Registration
|
||||||
|
@ -1442,6 +1443,7 @@ config.db_path_helper = (for "sqlite3" and "tidb")
|
||||||
config.service_config = Service Configuration
|
config.service_config = Service Configuration
|
||||||
config.register_email_confirm = Require Email Confirmation to Register
|
config.register_email_confirm = Require Email Confirmation to Register
|
||||||
config.disable_register = Disable Self-Registration
|
config.disable_register = Disable Self-Registration
|
||||||
|
config.allow_only_external_registration = Enable the registration only through external services
|
||||||
config.enable_openid_signup = Enable OpenID Self-Registration
|
config.enable_openid_signup = Enable OpenID Self-Registration
|
||||||
config.enable_openid_signin = Enable OpenID Sign-In
|
config.enable_openid_signin = Enable OpenID Sign-In
|
||||||
config.show_registration_button = Show Register Button
|
config.show_registration_button = Show Register Button
|
||||||
|
|
|
@ -112,6 +112,7 @@ func Install(ctx *context.Context) {
|
||||||
form.EnableOpenIDSignIn = setting.Service.EnableOpenIDSignIn
|
form.EnableOpenIDSignIn = setting.Service.EnableOpenIDSignIn
|
||||||
form.EnableOpenIDSignUp = setting.Service.EnableOpenIDSignUp
|
form.EnableOpenIDSignUp = setting.Service.EnableOpenIDSignUp
|
||||||
form.DisableRegistration = setting.Service.DisableRegistration
|
form.DisableRegistration = setting.Service.DisableRegistration
|
||||||
|
form.AllowOnlyExternalRegistration = setting.Service.AllowOnlyExternalRegistration
|
||||||
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
|
||||||
|
@ -304,6 +305,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
||||||
cfg.Section("openid").Key("ENABLE_OPENID_SIGNIN").SetValue(com.ToStr(form.EnableOpenIDSignIn))
|
cfg.Section("openid").Key("ENABLE_OPENID_SIGNIN").SetValue(com.ToStr(form.EnableOpenIDSignIn))
|
||||||
cfg.Section("openid").Key("ENABLE_OPENID_SIGNUP").SetValue(com.ToStr(form.EnableOpenIDSignUp))
|
cfg.Section("openid").Key("ENABLE_OPENID_SIGNUP").SetValue(com.ToStr(form.EnableOpenIDSignUp))
|
||||||
cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration))
|
cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration))
|
||||||
|
cfg.Section("service").Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").SetValue(com.ToStr(form.AllowOnlyExternalRegistration))
|
||||||
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))
|
||||||
|
|
|
@ -741,7 +741,8 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo
|
||||||
|
|
||||||
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
|
||||||
|
|
||||||
if setting.Service.DisableRegistration {
|
//Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
|
||||||
|
if !setting.Service.ShowRegistrationButton {
|
||||||
ctx.Error(403)
|
ctx.Error(403)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,8 @@
|
||||||
<dd><i class="fa fa{{if .Service.RegisterEmailConfirm}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Service.RegisterEmailConfirm}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.disable_register"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.disable_register"}}</dt>
|
||||||
<dd><i class="fa fa{{if .Service.DisableRegistration}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Service.DisableRegistration}}-check{{end}}-square-o"></i></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.allow_only_external_registration"}}</dt>
|
||||||
|
<dd><i class="fa fa{{if .Service.AllowOnlyExternalRegistration}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.show_registration_button"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.show_registration_button"}}</dt>
|
||||||
<dd><i class="fa fa{{if .Service.ShowRegistrationButton}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Service.ShowRegistrationButton}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.enable_openid_signup"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.enable_openid_signup"}}</dt>
|
||||||
|
|
6
templates/install.tmpl
vendored
6
templates/install.tmpl
vendored
|
@ -200,6 +200,12 @@
|
||||||
<input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
|
<input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<div class="ui checkbox" id="allow-only-external-registration">
|
||||||
|
<label class="poping up" data-content="{{.i18n.Tr "install.allow_only_external_registration_popup"}}"><strong>{{.i18n.Tr "install.allow_only_external_registration_popup"}}</strong></label>
|
||||||
|
<input name="allow_only_external_registration" type="checkbox" {{if .allow_only_external_registration}}checked{{end}}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<div class="ui checkbox" id="enable-openid-signup">
|
<div class="ui checkbox" id="enable-openid-signup">
|
||||||
<label class="poping up" data-content="{{.i18n.Tr "install.openid_signup_popup"}}"><strong>{{.i18n.Tr "install.openid_signup"}}</strong></label>
|
<label class="poping up" data-content="{{.i18n.Tr "install.openid_signup_popup"}}"><strong>{{.i18n.Tr "install.openid_signup"}}</strong></label>
|
||||||
|
|
Loading…
Reference in a new issue