]> source.dussan.org Git - gitea.git/commitdiff
Respect DefaultUserIsRestricted system default when creating new user (#19310 ) ...
authorJimmy Praet <jimmy.praet@telenet.be>
Sat, 30 Apr 2022 13:00:14 +0000 (15:00 +0200)
committerGitHub <noreply@github.com>
Sat, 30 Apr 2022 13:00:14 +0000 (15:00 +0200)
17 files changed:
cmd/admin.go
models/user/user.go
modules/structs/admin_user.go
routers/api/v1/admin/user.go
routers/install/install.go
routers/web/admin/users.go
routers/web/auth/auth.go
routers/web/auth/linkaccount.go
routers/web/auth/oauth.go
routers/web/auth/openid.go
services/auth/reverseproxy.go
services/auth/source/ldap/source_authenticate.go
services/auth/source/ldap/source_sync.go
services/auth/source/pam/source_authenticate.go
services/auth/source/smtp/source_authenticate.go
services/auth/sspi_windows.go
templates/swagger/v1_json.tmpl

index 3c7f7c8a7c5df4efcb0cd8b559d881c86efdfe53..1e524fe0953354ed7f0bab14c364d22ea3702d12 100644 (file)
@@ -25,6 +25,7 @@ import (
        repo_module "code.gitea.io/gitea/modules/repository"
        "code.gitea.io/gitea/modules/setting"
        "code.gitea.io/gitea/modules/storage"
+       "code.gitea.io/gitea/modules/util"
        auth_service "code.gitea.io/gitea/services/auth"
        "code.gitea.io/gitea/services/auth/source/oauth2"
        "code.gitea.io/gitea/services/auth/source/smtp"
@@ -113,6 +114,10 @@ var (
                                Name:  "access-token",
                                Usage: "Generate access token for the user",
                        },
+                       cli.BoolFlag{
+                               Name:  "restricted",
+                               Usage: "Make a restricted user account",
+                       },
                },
        }
 
@@ -537,17 +542,26 @@ func runCreateUser(c *cli.Context) error {
                changePassword = c.Bool("must-change-password")
        }
 
+       restricted := util.OptionalBoolNone
+
+       if c.IsSet("restricted") {
+               restricted = util.OptionalBoolOf(c.Bool("restricted"))
+       }
+
        u := &user_model.User{
                Name:               username,
                Email:              c.String("email"),
                Passwd:             password,
-               IsActive:           true,
                IsAdmin:            c.Bool("admin"),
                MustChangePassword: changePassword,
-               Theme:              setting.UI.DefaultTheme,
        }
 
-       if err := user_model.CreateUser(u); err != nil {
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsActive:     util.OptionalBoolTrue,
+               IsRestricted: restricted,
+       }
+
+       if err := user_model.CreateUser(u, overwriteDefault); err != nil {
                return fmt.Errorf("CreateUser: %v", err)
        }
 
index 735abed11c72b62256a866ed979fd8618a1d0c74..e375f3de0a5980791db1c3491b53888a4989a6aa 100644 (file)
@@ -622,7 +622,14 @@ func IsUsableUsername(name string) error {
 
 // CreateUserOverwriteOptions are an optional options who overwrite system defaults on user creation
 type CreateUserOverwriteOptions struct {
-       Visibility structs.VisibleType
+       KeepEmailPrivate             util.OptionalBool
+       Visibility                   *structs.VisibleType
+       AllowCreateOrganization      util.OptionalBool
+       EmailNotificationsPreference *string
+       MaxRepoCreation              *int
+       Theme                        *string
+       IsRestricted                 util.OptionalBool
+       IsActive                     util.OptionalBool
 }
 
 // CreateUser creates record of a new user.
@@ -638,10 +645,36 @@ func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err e
        u.EmailNotificationsPreference = setting.Admin.DefaultEmailNotification
        u.MaxRepoCreation = -1
        u.Theme = setting.UI.DefaultTheme
+       u.IsRestricted = setting.Service.DefaultUserIsRestricted
+       u.IsActive = !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm)
 
        // overwrite defaults if set
        if len(overwriteDefault) != 0 && overwriteDefault[0] != nil {
-               u.Visibility = overwriteDefault[0].Visibility
+               overwrite := overwriteDefault[0]
+               if !overwrite.KeepEmailPrivate.IsNone() {
+                       u.KeepEmailPrivate = overwrite.KeepEmailPrivate.IsTrue()
+               }
+               if overwrite.Visibility != nil {
+                       u.Visibility = *overwrite.Visibility
+               }
+               if !overwrite.AllowCreateOrganization.IsNone() {
+                       u.AllowCreateOrganization = overwrite.AllowCreateOrganization.IsTrue()
+               }
+               if overwrite.EmailNotificationsPreference != nil {
+                       u.EmailNotificationsPreference = *overwrite.EmailNotificationsPreference
+               }
+               if overwrite.MaxRepoCreation != nil {
+                       u.MaxRepoCreation = *overwrite.MaxRepoCreation
+               }
+               if overwrite.Theme != nil {
+                       u.Theme = *overwrite.Theme
+               }
+               if !overwrite.IsRestricted.IsNone() {
+                       u.IsRestricted = overwrite.IsRestricted.IsTrue()
+               }
+               if !overwrite.IsActive.IsNone() {
+                       u.IsActive = overwrite.IsActive.IsTrue()
+               }
        }
 
        // validate data
index facf16a39552aba43d8c870864af1abdd1051f56..eccbf29a46f0c0f6757b126b7f44a09f1519a6bf 100644 (file)
@@ -19,6 +19,7 @@ type CreateUserOption struct {
        Password           string `json:"password" binding:"Required;MaxSize(255)"`
        MustChangePassword *bool  `json:"must_change_password"`
        SendNotify         bool   `json:"send_notify"`
+       Restricted         *bool  `json:"restricted"`
        Visibility         string `json:"visibility" binding:"In(,public,limited,private)"`
 }
 
index 5b8d06120681dc5d107aae3745c5ad60241c3087..7262073bbd57bfdc13449af7136861778a4e134e 100644 (file)
@@ -22,6 +22,7 @@ import (
        "code.gitea.io/gitea/modules/password"
        "code.gitea.io/gitea/modules/setting"
        api "code.gitea.io/gitea/modules/structs"
+       "code.gitea.io/gitea/modules/util"
        "code.gitea.io/gitea/modules/web"
        "code.gitea.io/gitea/routers/api/v1/user"
        "code.gitea.io/gitea/routers/api/v1/utils"
@@ -81,7 +82,6 @@ func CreateUser(ctx *context.APIContext) {
                Email:              form.Email,
                Passwd:             form.Password,
                MustChangePassword: true,
-               IsActive:           true,
                LoginType:          auth.Plain,
        }
        if form.MustChangePassword != nil {
@@ -107,11 +107,17 @@ func CreateUser(ctx *context.APIContext) {
                return
        }
 
-       var overwriteDefault *user_model.CreateUserOverwriteOptions
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsActive: util.OptionalBoolTrue,
+       }
+
+       if form.Restricted != nil {
+               overwriteDefault.IsRestricted = util.OptionalBoolOf(*form.Restricted)
+       }
+
        if form.Visibility != "" {
-               overwriteDefault = &user_model.CreateUserOverwriteOptions{
-                       Visibility: api.VisibilityModes[form.Visibility],
-               }
+               visibility := api.VisibilityModes[form.Visibility]
+               overwriteDefault.Visibility = &visibility
        }
 
        if err := user_model.CreateUser(u, overwriteDefault); err != nil {
index 7c3d43bbde074ddd21e1f8a1af303677164bfea3..1633b174ec464a028c325f38e8537548fbe0d1be 100644 (file)
@@ -508,13 +508,17 @@ func SubmitInstall(ctx *context.Context) {
        // Create admin account
        if len(form.AdminName) > 0 {
                u := &user_model.User{
-                       Name:     form.AdminName,
-                       Email:    form.AdminEmail,
-                       Passwd:   form.AdminPasswd,
-                       IsAdmin:  true,
-                       IsActive: true,
+                       Name:    form.AdminName,
+                       Email:   form.AdminEmail,
+                       Passwd:  form.AdminPasswd,
+                       IsAdmin: true,
                }
-               if err = user_model.CreateUser(u); err != nil {
+               overwriteDefault := &user_model.CreateUserOverwriteOptions{
+                       IsRestricted: util.OptionalBoolFalse,
+                       IsActive:     util.OptionalBoolTrue,
+               }
+
+               if err = user_model.CreateUser(u, overwriteDefault); err != nil {
                        if !user_model.IsErrUserAlreadyExist(err) {
                                setting.InstallLock = false
                                ctx.Data["Err_AdminName"] = true
index a7d7d62d9a60a0cfb34a9fc2ce8d48f93ad8f0d3..1576f58b4105fb48d67de0d60105463a0ca03190 100644 (file)
@@ -125,10 +125,14 @@ func NewUserPost(ctx *context.Context) {
                Name:      form.UserName,
                Email:     form.Email,
                Passwd:    form.Password,
-               IsActive:  true,
                LoginType: auth.Plain,
        }
 
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsActive:   util.OptionalBoolTrue,
+               Visibility: &form.Visibility,
+       }
+
        if len(form.LoginType) > 0 {
                fields := strings.Split(form.LoginType, "-")
                if len(fields) == 2 {
@@ -163,7 +167,7 @@ func NewUserPost(ctx *context.Context) {
                u.MustChangePassword = form.MustChangePassword
        }
 
-       if err := user_model.CreateUser(u, &user_model.CreateUserOverwriteOptions{Visibility: form.Visibility}); err != nil {
+       if err := user_model.CreateUser(u, overwriteDefault); err != nil {
                switch {
                case user_model.IsErrUserAlreadyExist(err):
                        ctx.Data["Err_UserName"] = true
index e0a2776926e24b28283ca86e2af5558821c72e61..5e0b338baf136969df5d2c5c71f313e020848bad 100644 (file)
@@ -507,14 +507,12 @@ func SignUpPost(ctx *context.Context) {
        }
 
        u := &user_model.User{
-               Name:         form.UserName,
-               Email:        form.Email,
-               Passwd:       form.Password,
-               IsActive:     !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
-               IsRestricted: setting.Service.DefaultUserIsRestricted,
+               Name:   form.UserName,
+               Email:  form.Email,
+               Passwd: form.Password,
        }
 
-       if !createAndHandleCreatedUser(ctx, tplSignUp, form, u, nil, false) {
+       if !createAndHandleCreatedUser(ctx, tplSignUp, form, u, nil, nil, false) {
                // error already handled
                return
        }
@@ -525,8 +523,8 @@ func SignUpPost(ctx *context.Context) {
 
 // createAndHandleCreatedUser calls createUserInContext and
 // then handleUserCreated.
-func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, gothUser *goth.User, allowLink bool) bool {
-       if !createUserInContext(ctx, tpl, form, u, gothUser, allowLink) {
+func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) bool {
+       if !createUserInContext(ctx, tpl, form, u, overwrites, gothUser, allowLink) {
                return false
        }
        return handleUserCreated(ctx, u, gothUser)
@@ -534,8 +532,8 @@ func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form int
 
 // createUserInContext creates a user and handles errors within a given context.
 // Optionally a template can be specified.
-func createUserInContext(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, gothUser *goth.User, allowLink bool) (ok bool) {
-       if err := user_model.CreateUser(u); err != nil {
+func createUserInContext(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) {
+       if err := user_model.CreateUser(u, overwrites); err != nil {
                if allowLink && (user_model.IsErrUserAlreadyExist(err) || user_model.IsErrEmailAlreadyUsed(err)) {
                        if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingAuto {
                                var user *user_model.User
index 27eb954a581a5ac15b46c25f906aa9dc608feb68..59e314b7c2c9d69b23aa8b54e615fde2179d13bc 100644 (file)
@@ -285,13 +285,12 @@ func LinkAccountPostRegister(ctx *context.Context) {
                Name:        form.UserName,
                Email:       form.Email,
                Passwd:      form.Password,
-               IsActive:    !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
                LoginType:   auth.OAuth2,
                LoginSource: authSource.ID,
                LoginName:   gothUser.UserID,
        }
 
-       if !createAndHandleCreatedUser(ctx, tplLinkAccount, form, u, &gothUser, false) {
+       if !createAndHandleCreatedUser(ctx, tplLinkAccount, form, u, nil, &gothUser, false) {
                // error already handled
                return
        }
index 8bd443a6c99bcef0b3904208a9c263d30f166450..313cd804eb0d6222410c8fff6f143c9fec301b45 100644 (file)
@@ -25,6 +25,7 @@ import (
        "code.gitea.io/gitea/modules/session"
        "code.gitea.io/gitea/modules/setting"
        "code.gitea.io/gitea/modules/timeutil"
+       "code.gitea.io/gitea/modules/util"
        "code.gitea.io/gitea/modules/web"
        "code.gitea.io/gitea/modules/web/middleware"
        auth_service "code.gitea.io/gitea/services/auth"
@@ -872,19 +873,21 @@ func SignInOAuthCallback(ctx *context.Context) {
                                return
                        }
                        u = &user_model.User{
-                               Name:         getUserName(&gothUser),
-                               FullName:     gothUser.Name,
-                               Email:        gothUser.Email,
-                               IsActive:     !setting.OAuth2Client.RegisterEmailConfirm,
-                               LoginType:    auth.OAuth2,
-                               LoginSource:  authSource.ID,
-                               LoginName:    gothUser.UserID,
-                               IsRestricted: setting.Service.DefaultUserIsRestricted,
+                               Name:        getUserName(&gothUser),
+                               FullName:    gothUser.Name,
+                               Email:       gothUser.Email,
+                               LoginType:   auth.OAuth2,
+                               LoginSource: authSource.ID,
+                               LoginName:   gothUser.UserID,
+                       }
+
+                       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+                               IsActive: util.OptionalBoolOf(!setting.OAuth2Client.RegisterEmailConfirm),
                        }
 
                        setUserGroupClaims(authSource, u, &gothUser)
 
-                       if !createAndHandleCreatedUser(ctx, base.TplName(""), nil, u, &gothUser, setting.OAuth2Client.AccountLinking != setting.OAuth2AccountLinkingDisabled) {
+                       if !createAndHandleCreatedUser(ctx, base.TplName(""), nil, u, overwriteDefault, &gothUser, setting.OAuth2Client.AccountLinking != setting.OAuth2AccountLinkingDisabled) {
                                // error already handled
                                return
                        }
index 4395641795fd1595b17be347298eb4c6790b12b1..4450aefbe34653ec62edbdb29eb6d8b2fc2278b3 100644 (file)
@@ -425,12 +425,11 @@ func RegisterOpenIDPost(ctx *context.Context) {
        }
 
        u := &user_model.User{
-               Name:     form.UserName,
-               Email:    form.Email,
-               Passwd:   password,
-               IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
+               Name:   form.UserName,
+               Email:  form.Email,
+               Passwd: password,
        }
-       if !createUserInContext(ctx, tplSignUpOID, form, u, nil, false) {
+       if !createUserInContext(ctx, tplSignUpOID, form, u, nil, nil, false) {
                // error already handled
                return
        }
index 3e44d8b8639cac1d2dca3e6d9b52ebf0791c1154..d2b0ab2148ae935d65e82eb4c54f9925901ccde9 100644 (file)
@@ -12,6 +12,7 @@ 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"
 
@@ -106,11 +107,15 @@ func (r *ReverseProxy) newUser(req *http.Request) *user_model.User {
        }
 
        user := &user_model.User{
-               Name:     username,
-               Email:    email,
-               IsActive: true,
+               Name:  username,
+               Email: email,
        }
-       if err := user_model.CreateUser(user); err != nil {
+
+       overwriteDefault := user_model.CreateUserOverwriteOptions{
+               IsActive: util.OptionalBoolTrue,
+       }
+
+       if err := user_model.CreateUser(user, &overwriteDefault); err != nil {
                // FIXME: should I create a system notice?
                log.Error("CreateUser: %v", err)
                return nil
index bc35bc20f6563ea0fc1ba9817694041f1b891c50..c5e3677a2b3f2456d83c6f389da2ffbe76693c04 100644 (file)
@@ -12,6 +12,7 @@ import (
        "code.gitea.io/gitea/models/auth"
        "code.gitea.io/gitea/models/db"
        user_model "code.gitea.io/gitea/models/user"
+       "code.gitea.io/gitea/modules/util"
        "code.gitea.io/gitea/services/mailer"
        user_service "code.gitea.io/gitea/services/user"
 )
@@ -80,19 +81,21 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str
        }
 
        user = &user_model.User{
-               LowerName:    strings.ToLower(sr.Username),
-               Name:         sr.Username,
-               FullName:     composeFullName(sr.Name, sr.Surname, sr.Username),
-               Email:        sr.Mail,
-               LoginType:    source.authSource.Type,
-               LoginSource:  source.authSource.ID,
-               LoginName:    userName,
-               IsActive:     true,
-               IsAdmin:      sr.IsAdmin,
-               IsRestricted: sr.IsRestricted,
+               LowerName:   strings.ToLower(sr.Username),
+               Name:        sr.Username,
+               FullName:    composeFullName(sr.Name, sr.Surname, sr.Username),
+               Email:       sr.Mail,
+               LoginType:   source.authSource.Type,
+               LoginSource: source.authSource.ID,
+               LoginName:   userName,
+               IsAdmin:     sr.IsAdmin,
+       }
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsRestricted: util.OptionalBoolOf(sr.IsRestricted),
+               IsActive:     util.OptionalBoolTrue,
        }
 
-       err := user_model.CreateUser(user)
+       err := user_model.CreateUser(user, overwriteDefault)
        if err != nil {
                return user, err
        }
index a7f06fcc9e5632d7612a1a3df7771d9b19597afd..37b07cf31624292302bf1f6b14dcae856041aa1a 100644 (file)
@@ -14,6 +14,7 @@ import (
        "code.gitea.io/gitea/models/db"
        user_model "code.gitea.io/gitea/models/user"
        "code.gitea.io/gitea/modules/log"
+       "code.gitea.io/gitea/modules/util"
        user_service "code.gitea.io/gitea/services/user"
 )
 
@@ -99,19 +100,21 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error {
                        log.Trace("SyncExternalUsers[%s]: Creating user %s", source.authSource.Name, su.Username)
 
                        usr = &user_model.User{
-                               LowerName:    su.LowerName,
-                               Name:         su.Username,
-                               FullName:     fullName,
-                               LoginType:    source.authSource.Type,
-                               LoginSource:  source.authSource.ID,
-                               LoginName:    su.Username,
-                               Email:        su.Mail,
-                               IsAdmin:      su.IsAdmin,
-                               IsRestricted: su.IsRestricted,
-                               IsActive:     true,
+                               LowerName:   su.LowerName,
+                               Name:        su.Username,
+                               FullName:    fullName,
+                               LoginType:   source.authSource.Type,
+                               LoginSource: source.authSource.ID,
+                               LoginName:   su.Username,
+                               Email:       su.Mail,
+                               IsAdmin:     su.IsAdmin,
+                       }
+                       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+                               IsRestricted: util.OptionalBoolOf(su.IsRestricted),
+                               IsActive:     util.OptionalBoolTrue,
                        }
 
-                       err = user_model.CreateUser(usr)
+                       err = user_model.CreateUser(usr, overwriteDefault)
 
                        if err != nil {
                                log.Error("SyncExternalUsers[%s]: Error creating user %s: %v", source.authSource.Name, su.Username, err)
index d5bd9409963f081ba7aeb9d2a60d5f8570fc225c..16ddc0598e47fd5023f2b4f18d212047bc362583 100644 (file)
@@ -12,6 +12,7 @@ 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"
@@ -58,10 +59,12 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str
                LoginType:   auth.PAM,
                LoginSource: source.authSource.ID,
                LoginName:   userName, // This is what the user typed in
-               IsActive:    true,
+       }
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsActive: util.OptionalBoolTrue,
        }
 
-       if err := user_model.CreateUser(user); err != nil {
+       if err := user_model.CreateUser(user, overwriteDefault); err != nil {
                return user, err
        }
 
index 3be2f1128de2f39dc4d85b58f2c87bd615a6ea0f..dff24d494ee0f6543c8c06854cfb44ba5babfa4c 100644 (file)
@@ -74,10 +74,12 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str
                LoginType:   auth_model.SMTP,
                LoginSource: source.authSource.ID,
                LoginName:   userName,
-               IsActive:    true,
+       }
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsActive: util.OptionalBoolTrue,
        }
 
-       if err := user_model.CreateUser(user); err != nil {
+       if err := user_model.CreateUser(user, overwriteDefault); err != nil {
                return user, err
        }
 
index cadf72179646f3f7f2d690142de9a140c56f2987..55732a6be0a9e899936f096fd06c129a4b8346df 100644 (file)
@@ -16,6 +16,7 @@ import (
        "code.gitea.io/gitea/modules/log"
        "code.gitea.io/gitea/modules/setting"
        "code.gitea.io/gitea/modules/templates"
+       "code.gitea.io/gitea/modules/util"
        "code.gitea.io/gitea/modules/web/middleware"
        "code.gitea.io/gitea/services/auth/source/sspi"
        "code.gitea.io/gitea/services/mailer"
@@ -187,17 +188,20 @@ func (s *SSPI) shouldAuthenticate(req *http.Request) (shouldAuth bool) {
 func (s *SSPI) newUser(username string, cfg *sspi.Source) (*user_model.User, error) {
        email := gouuid.New().String() + "@localhost.localdomain"
        user := &user_model.User{
-               Name:                         username,
-               Email:                        email,
-               KeepEmailPrivate:             true,
-               Passwd:                       gouuid.New().String(),
-               IsActive:                     cfg.AutoActivateUsers,
-               Language:                     cfg.DefaultLanguage,
-               UseCustomAvatar:              true,
-               Avatar:                       avatars.DefaultAvatarLink(),
-               EmailNotificationsPreference: user_model.EmailNotificationsDisabled,
+               Name:            username,
+               Email:           email,
+               Passwd:          gouuid.New().String(),
+               Language:        cfg.DefaultLanguage,
+               UseCustomAvatar: true,
+               Avatar:          avatars.DefaultAvatarLink(),
        }
-       if err := user_model.CreateUser(user); err != nil {
+       emailNotificationPreference := user_model.EmailNotificationsDisabled
+       overwriteDefault := &user_model.CreateUserOverwriteOptions{
+               IsActive:                     util.OptionalBoolOf(cfg.AutoActivateUsers),
+               KeepEmailPrivate:             util.OptionalBoolTrue,
+               EmailNotificationsPreference: &emailNotificationPreference,
+       }
+       if err := user_model.CreateUser(user, overwriteDefault); err != nil {
                return nil, err
        }
 
index 1085dcba4ecda65ac8cee23b78ce3b6928b67a3b..791ada03fd99466921f99c206e108050fc6aff31 100644 (file)
           "type": "string",
           "x-go-name": "Password"
         },
+        "restricted": {
+          "type": "boolean",
+          "x-go-name": "Restricted"
+        },
         "send_notify": {
           "type": "boolean",
           "x-go-name": "SendNotify"