summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Vlasak <jiri.hubacek@gmail.com>2020-12-20 02:31:06 +0100
committerGitHub <noreply@github.com>2020-12-19 20:31:06 -0500
commitd7c67a9fb255cfb95876d72cd9fd79247d33f5ef (patch)
treea9b6e7721e874ecff2ec4cc3f0fbceb009f48e05
parent36bd5d70cd390d59d1440b2e68bd3170d6af7ca2 (diff)
downloadgitea-d7c67a9fb255cfb95876d72cd9fd79247d33f5ef.tar.gz
gitea-d7c67a9fb255cfb95876d72cd9fd79247d33f5ef.zip
Manually approve new registration (#13083)
* Add register manual confirm settings option The new settings option is used when manually approving new registrations. * Enable manual confirmation of new registered user When manual registration confirmation is desired (by default `false`) create new user in the database that is *not active*. The user must then be activated manually. This change speeds up the process of adding new confirmed users for Gitea instances without external auth mechanism. (Currently the option is to manually create new user by admin.) * Update docs/content/doc/advanced/config-cheat-sheet.zh-cn.md Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r--custom/conf/app.example.ini2
-rw-r--r--docs/content/doc/advanced/config-cheat-sheet.en-us.md2
-rw-r--r--docs/content/doc/advanced/config-cheat-sheet.zh-cn.md1
-rw-r--r--integrations/mssql.ini.tmpl1
-rw-r--r--integrations/mysql.ini.tmpl1
-rw-r--r--integrations/mysql8.ini.tmpl1
-rw-r--r--integrations/pgsql.ini.tmpl1
-rw-r--r--integrations/sqlite.ini.tmpl1
-rw-r--r--modules/setting/service.go6
-rw-r--r--routers/user/auth.go4
10 files changed, 18 insertions, 2 deletions
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 6a4e0ca02f..1e77ff2706 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -597,6 +597,8 @@ ACTIVE_CODE_LIVE_MINUTES = 180
RESET_PASSWD_CODE_LIVE_MINUTES = 180
; Whether a new user needs to confirm their email when registering.
REGISTER_EMAIL_CONFIRM = false
+; Whether a new user needs to be confirmed manually after registration. (Requires `REGISTER_EMAIL_CONFIRM` to be disabled.)
+REGISTER_MANUAL_CONFIRM = false
; List of domain names that are allowed to be used to register on a Gitea instance
; gitea.io,example.com
EMAIL_DOMAIN_WHITELIST =
diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
index 2cd175dbfc..e30e740f7f 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
@@ -422,6 +422,8 @@ relation to port exhaustion.
process.
- `REGISTER_EMAIL_CONFIRM`: **false**: Enable this to ask for mail confirmation of registration.
Requires `Mailer` to be enabled.
+- `REGISTER_MANUAL_CONFIRM`: **false**: Enable this to manually confirm new registrations.
+ Requires `REGISTER_EMAIL_CONFIRM` to be disabled.
- `DISABLE_REGISTRATION`: **false**: Disable registration, after which only admin can create
accounts for users.
- `REQUIRE_EXTERNAL_REGISTRATION_PASSWORD`: **false**: Enable this to force externally created
diff --git a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
index 9ba46e3579..c1f7e836c0 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
@@ -124,6 +124,7 @@ menu:
- `ACTIVE_CODE_LIVE_MINUTES`: 登录验证码失效时间,单位分钟。
- `RESET_PASSWD_CODE_LIVE_MINUTES`: 重置密码失效时间,单位分钟。
- `REGISTER_EMAIL_CONFIRM`: 启用注册邮件激活,前提是 `Mailer` 已经启用。
+- `REGISTER_MANUAL_CONFIRM`: **false**: 新注册用户必须由管理员手动激活,启用此选项需取消`REGISTER_EMAIL_CONFIRM`.
- `DISABLE_REGISTRATION`: 禁用注册,启用后只能用管理员添加用户。
- `SHOW_REGISTRATION_BUTTON`: 是否显示注册按钮。
- `REQUIRE_SIGNIN_VIEW`: 是否所有页面都必须登录后才可访问。
diff --git a/integrations/mssql.ini.tmpl b/integrations/mssql.ini.tmpl
index 7a51871fc0..44c0a7eed9 100644
--- a/integrations/mssql.ini.tmpl
+++ b/integrations/mssql.ini.tmpl
@@ -55,6 +55,7 @@ FROM = mssql-integration-test@gitea.io
[service]
REGISTER_EMAIL_CONFIRM = false
+REGISTER_MANUAL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false
diff --git a/integrations/mysql.ini.tmpl b/integrations/mysql.ini.tmpl
index db1051e62a..2b044498eb 100644
--- a/integrations/mysql.ini.tmpl
+++ b/integrations/mysql.ini.tmpl
@@ -76,6 +76,7 @@ FROM = mysql-integration-test@gitea.io
[service]
REGISTER_EMAIL_CONFIRM = false
+REGISTER_MANUAL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false
diff --git a/integrations/mysql8.ini.tmpl b/integrations/mysql8.ini.tmpl
index d6fcbc1dd5..798ab7852a 100644
--- a/integrations/mysql8.ini.tmpl
+++ b/integrations/mysql8.ini.tmpl
@@ -50,6 +50,7 @@ ENABLED = false
[service]
REGISTER_EMAIL_CONFIRM = false
+REGISTER_MANUAL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false
diff --git a/integrations/pgsql.ini.tmpl b/integrations/pgsql.ini.tmpl
index 523def788f..5f082f04e1 100644
--- a/integrations/pgsql.ini.tmpl
+++ b/integrations/pgsql.ini.tmpl
@@ -56,6 +56,7 @@ FROM = pgsql-integration-test@gitea.io
[service]
REGISTER_EMAIL_CONFIRM = false
+REGISTER_MANUAL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false
diff --git a/integrations/sqlite.ini.tmpl b/integrations/sqlite.ini.tmpl
index 4c9dce4bb1..5ed096b0a3 100644
--- a/integrations/sqlite.ini.tmpl
+++ b/integrations/sqlite.ini.tmpl
@@ -52,6 +52,7 @@ FROM = sqlite-integration-test@gitea.io
[service]
REGISTER_EMAIL_CONFIRM = false
+REGISTER_MANUAL_CONFIRM = false
ENABLE_NOTIFY_MAIL = true
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = false
diff --git a/modules/setting/service.go b/modules/setting/service.go
index 4d03df17a4..5e74641d27 100644
--- a/modules/setting/service.go
+++ b/modules/setting/service.go
@@ -17,6 +17,7 @@ var Service struct {
ActiveCodeLives int
ResetPwdCodeLives int
RegisterEmailConfirm bool
+ RegisterManualConfirm bool
EmailDomainWhitelist []string
DisableRegistration bool
AllowOnlyExternalRegistration bool
@@ -63,6 +64,11 @@ func newService() {
Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
+ if !sec.Key("REGISTER_EMAIL_CONFIRM").MustBool() {
+ Service.RegisterManualConfirm = sec.Key("REGISTER_EMAIL_CONFIRM").MustBool(false)
+ } else {
+ Service.RegisterManualConfirm = false
+ }
Service.EmailDomainWhitelist = sec.Key("EMAIL_DOMAIN_WHITELIST").Strings(",")
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
Service.ShowMilestonesDashboardPage = sec.Key("SHOW_MILESTONES_DASHBOARD_PAGE").MustBool(true)
diff --git a/routers/user/auth.go b/routers/user/auth.go
index 1e34099411..acd88b364c 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -949,7 +949,7 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au
Name: form.UserName,
Email: form.Email,
Passwd: form.Password,
- IsActive: !setting.Service.RegisterEmailConfirm,
+ IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
LoginType: models.LoginOAuth2,
LoginSource: loginSource.ID,
LoginName: gothUser.(goth.User).UserID,
@@ -1144,7 +1144,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo
Name: form.UserName,
Email: form.Email,
Passwd: form.Password,
- IsActive: !setting.Service.RegisterEmailConfirm,
+ IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
}
if err := models.CreateUser(u); err != nil {
switch {