Skip to content

Commit

Permalink
Respect default setting.Service.RegisterEmailConfirm and setting.Serv…
Browse files Browse the repository at this point in the history
…ice.RegisterManualConfirm where needed
  • Loading branch information
jpraet committed Apr 10, 2022
1 parent a8dc6ec commit ee95d3e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion routers/web/auth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions services/auth/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion services/auth/source/ldap/source_authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions services/auth/source/pam/source_authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 1 addition & 4 deletions services/auth/source/smtp/source_authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ee95d3e

Please sign in to comment.