|
|
@ -25,6 +25,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/container" |
|
|
|
"code.gitea.io/gitea/modules/container" |
|
|
|
"code.gitea.io/gitea/modules/git" |
|
|
|
"code.gitea.io/gitea/modules/git" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/optional" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/structs" |
|
|
|
"code.gitea.io/gitea/modules/structs" |
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
@ -573,14 +574,14 @@ func IsUsableUsername(name string) error { |
|
|
|
|
|
|
|
|
|
|
|
// CreateUserOverwriteOptions are an optional options who overwrite system defaults on user creation
|
|
|
|
// CreateUserOverwriteOptions are an optional options who overwrite system defaults on user creation
|
|
|
|
type CreateUserOverwriteOptions struct { |
|
|
|
type CreateUserOverwriteOptions struct { |
|
|
|
KeepEmailPrivate util.OptionalBool |
|
|
|
KeepEmailPrivate optional.Option[bool] |
|
|
|
Visibility *structs.VisibleType |
|
|
|
Visibility *structs.VisibleType |
|
|
|
AllowCreateOrganization util.OptionalBool |
|
|
|
AllowCreateOrganization optional.Option[bool] |
|
|
|
EmailNotificationsPreference *string |
|
|
|
EmailNotificationsPreference *string |
|
|
|
MaxRepoCreation *int |
|
|
|
MaxRepoCreation *int |
|
|
|
Theme *string |
|
|
|
Theme *string |
|
|
|
IsRestricted util.OptionalBool |
|
|
|
IsRestricted optional.Option[bool] |
|
|
|
IsActive util.OptionalBool |
|
|
|
IsActive optional.Option[bool] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CreateUser creates record of a new user.
|
|
|
|
// CreateUser creates record of a new user.
|
|
|
@ -607,14 +608,14 @@ func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOve |
|
|
|
// overwrite defaults if set
|
|
|
|
// overwrite defaults if set
|
|
|
|
if len(overwriteDefault) != 0 && overwriteDefault[0] != nil { |
|
|
|
if len(overwriteDefault) != 0 && overwriteDefault[0] != nil { |
|
|
|
overwrite := overwriteDefault[0] |
|
|
|
overwrite := overwriteDefault[0] |
|
|
|
if !overwrite.KeepEmailPrivate.IsNone() { |
|
|
|
if overwrite.KeepEmailPrivate.Has() { |
|
|
|
u.KeepEmailPrivate = overwrite.KeepEmailPrivate.IsTrue() |
|
|
|
u.KeepEmailPrivate = overwrite.KeepEmailPrivate.Value() |
|
|
|
} |
|
|
|
} |
|
|
|
if overwrite.Visibility != nil { |
|
|
|
if overwrite.Visibility != nil { |
|
|
|
u.Visibility = *overwrite.Visibility |
|
|
|
u.Visibility = *overwrite.Visibility |
|
|
|
} |
|
|
|
} |
|
|
|
if !overwrite.AllowCreateOrganization.IsNone() { |
|
|
|
if overwrite.AllowCreateOrganization.Has() { |
|
|
|
u.AllowCreateOrganization = overwrite.AllowCreateOrganization.IsTrue() |
|
|
|
u.AllowCreateOrganization = overwrite.AllowCreateOrganization.Value() |
|
|
|
} |
|
|
|
} |
|
|
|
if overwrite.EmailNotificationsPreference != nil { |
|
|
|
if overwrite.EmailNotificationsPreference != nil { |
|
|
|
u.EmailNotificationsPreference = *overwrite.EmailNotificationsPreference |
|
|
|
u.EmailNotificationsPreference = *overwrite.EmailNotificationsPreference |
|
|
@ -625,11 +626,11 @@ func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOve |
|
|
|
if overwrite.Theme != nil { |
|
|
|
if overwrite.Theme != nil { |
|
|
|
u.Theme = *overwrite.Theme |
|
|
|
u.Theme = *overwrite.Theme |
|
|
|
} |
|
|
|
} |
|
|
|
if !overwrite.IsRestricted.IsNone() { |
|
|
|
if overwrite.IsRestricted.Has() { |
|
|
|
u.IsRestricted = overwrite.IsRestricted.IsTrue() |
|
|
|
u.IsRestricted = overwrite.IsRestricted.Value() |
|
|
|
} |
|
|
|
} |
|
|
|
if !overwrite.IsActive.IsNone() { |
|
|
|
if overwrite.IsActive.Has() { |
|
|
|
u.IsActive = overwrite.IsActive.IsTrue() |
|
|
|
u.IsActive = overwrite.IsActive.Value() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|