]> source.dussan.org Git - gitea.git/commitdiff
Manually approve new registration (#13083)
authorJiri Vlasak <jiri.hubacek@gmail.com>
Sun, 20 Dec 2020 01:31:06 +0000 (02:31 +0100)
committerGitHub <noreply@github.com>
Sun, 20 Dec 2020 01:31:06 +0000 (20:31 -0500)
* 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>
custom/conf/app.example.ini
docs/content/doc/advanced/config-cheat-sheet.en-us.md
docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
integrations/mssql.ini.tmpl
integrations/mysql.ini.tmpl
integrations/mysql8.ini.tmpl
integrations/pgsql.ini.tmpl
integrations/sqlite.ini.tmpl
modules/setting/service.go
routers/user/auth.go

index 6a4e0ca02f428eb8a47289acb82abbbef61a947d..1e77ff270658ce792cf993976699ba9c487753de 100644 (file)
@@ -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 =
index 2cd175dbfc2dd348d403fe3f951429a8a0704081..e30e740f7f18385b5bf5d1bce4c2b3af55cffe45 100644 (file)
@@ -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
index 9ba46e357999d1f2fc5b47b8973048dfbacf4095..c1f7e836c01a8ded873ad74a06641eb9a67228d3 100644 (file)
@@ -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`: 是否所有页面都必须登录后才可访问。
index 7a51871fc0cb71eabbde35f5df93aa96504ab4fc..44c0a7eed9fbb23eeae740e2e683810959fd9c8b 100644 (file)
@@ -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
index db1051e62a39a115ffce0d18b7123d206baee34d..2b044498ebd4e71faeb61335659717ffa52045b7 100644 (file)
@@ -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
index d6fcbc1dd51c348ecb7f08d4e2a3496b305b42b0..798ab7852acaed032fd11c35cccedda82b7a3933 100644 (file)
@@ -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
index 523def788f741ea835376be2901bacf02f9c8fa3..5f082f04e1a76e7e0cfb18d2d98722502729cb52 100644 (file)
@@ -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
index 4c9dce4bb1838aa76897315883eaa17ee8fcb3b2..5ed096b0a3896ac0efd148e2ba0a718100e02a93 100644 (file)
@@ -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
index 4d03df17a4bf5421fc2951478b9d193cea34a74a..5e74641d2705c60fb28d058ed4f474ab4063641f 100644 (file)
@@ -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)
index 1e340994118c59e5760fde990ca91b48b369caff..acd88b364c3b17c5ad438ccdabe09ec036730d41 100644 (file)
@@ -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 {