From ee95d3e8dc9e9fff4fa66a5111e4d3930280e033 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sun, 10 Apr 2022 08:52:46 +0200 Subject: [PATCH] Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed --- routers/web/auth/oauth.go | 2 +- services/auth/reverseproxy.go | 7 +------ services/auth/source/ldap/source_authenticate.go | 1 - services/auth/source/pam/source_authenticate.go | 6 +----- services/auth/source/smtp/source_authenticate.go | 5 +---- 5 files changed, 4 insertions(+), 17 deletions(-) diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 4c3e3c3ace..e7ef1faab7 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -877,7 +877,7 @@ func SignInOAuthCallback(ctx *context.Context) { } overwriteDefault := &user_model.CreateUserOverwriteOptions{ - IsActive: util.OptionalBoolOf(!setting.OAuth2Client.RegisterEmailConfirm), + IsActive: util.OptionalBoolOf(!(setting.OAuth2Client.RegisterEmailConfirm || setting.Service.RegisterManualConfirm)), } setUserGroupClaims(authSource, u, &gothUser) diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index 299d7abd34..698902b1cf 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -12,7 +12,6 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/services/mailer" @@ -110,11 +109,7 @@ func (r *ReverseProxy) newUser(req *http.Request) *user_model.User { Email: email, } - overwriteDefault := user_model.CreateUserOverwriteOptions{ - IsActive: util.OptionalBoolTrue, - } - - if err := user_model.CreateUser(user, &overwriteDefault); err != nil { + if err := user_model.CreateUser(user); err != nil { // FIXME: should I create a system notice? log.Error("CreateUser: %v", err) return nil diff --git a/services/auth/source/ldap/source_authenticate.go b/services/auth/source/ldap/source_authenticate.go index d8d11f18e1..3a8866ef67 100644 --- a/services/auth/source/ldap/source_authenticate.go +++ b/services/auth/source/ldap/source_authenticate.go @@ -97,7 +97,6 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str } overwriteDefault := &user_model.CreateUserOverwriteOptions{ IsRestricted: util.OptionalBoolOf(sr.IsRestricted), - IsActive: util.OptionalBoolTrue, } err := user_model.CreateUser(user, overwriteDefault) diff --git a/services/auth/source/pam/source_authenticate.go b/services/auth/source/pam/source_authenticate.go index 16ddc0598e..9ab1724ad5 100644 --- a/services/auth/source/pam/source_authenticate.go +++ b/services/auth/source/pam/source_authenticate.go @@ -12,7 +12,6 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/auth/pam" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/mailer" "github.com/google/uuid" @@ -60,11 +59,8 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str LoginSource: source.authSource.ID, LoginName: userName, // This is what the user typed in } - overwriteDefault := &user_model.CreateUserOverwriteOptions{ - IsActive: util.OptionalBoolTrue, - } - if err := user_model.CreateUser(user, overwriteDefault); err != nil { + if err := user_model.CreateUser(user); err != nil { return user, err } diff --git a/services/auth/source/smtp/source_authenticate.go b/services/auth/source/smtp/source_authenticate.go index dff24d494e..53a75773c1 100644 --- a/services/auth/source/smtp/source_authenticate.go +++ b/services/auth/source/smtp/source_authenticate.go @@ -75,11 +75,8 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str LoginSource: source.authSource.ID, LoginName: userName, } - overwriteDefault := &user_model.CreateUserOverwriteOptions{ - IsActive: util.OptionalBoolTrue, - } - if err := user_model.CreateUser(user, overwriteDefault); err != nil { + if err := user_model.CreateUser(user); err != nil { return user, err }