@@ -25,6 +25,7 @@ import (
2525 "code.gitea.io/gitea/modules/container"
2626 "code.gitea.io/gitea/modules/git"
2727 "code.gitea.io/gitea/modules/log"
28+ "code.gitea.io/gitea/modules/optional"
2829 "code.gitea.io/gitea/modules/setting"
2930 "code.gitea.io/gitea/modules/structs"
3031 "code.gitea.io/gitea/modules/timeutil"
@@ -573,14 +574,14 @@ func IsUsableUsername(name string) error {
573574
574575// CreateUserOverwriteOptions are an optional options who overwrite system defaults on user creation
575576type CreateUserOverwriteOptions struct {
576- KeepEmailPrivate util. OptionalBool
577+ KeepEmailPrivate optional. Option [ bool ]
577578 Visibility * structs.VisibleType
578- AllowCreateOrganization util. OptionalBool
579+ AllowCreateOrganization optional. Option [ bool ]
579580 EmailNotificationsPreference * string
580581 MaxRepoCreation * int
581582 Theme * string
582- IsRestricted util. OptionalBool
583- IsActive util. OptionalBool
583+ IsRestricted optional. Option [ bool ]
584+ IsActive optional. Option [ bool ]
584585}
585586
586587// CreateUser creates record of a new user.
@@ -607,14 +608,14 @@ func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOve
607608 // overwrite defaults if set
608609 if len (overwriteDefault ) != 0 && overwriteDefault [0 ] != nil {
609610 overwrite := overwriteDefault [0 ]
610- if ! overwrite .KeepEmailPrivate .IsNone () {
611- u .KeepEmailPrivate = overwrite .KeepEmailPrivate .IsTrue ()
611+ if overwrite .KeepEmailPrivate .Has () {
612+ u .KeepEmailPrivate = overwrite .KeepEmailPrivate .Value ()
612613 }
613614 if overwrite .Visibility != nil {
614615 u .Visibility = * overwrite .Visibility
615616 }
616- if ! overwrite .AllowCreateOrganization .IsNone () {
617- u .AllowCreateOrganization = overwrite .AllowCreateOrganization .IsTrue ()
617+ if overwrite .AllowCreateOrganization .Has () {
618+ u .AllowCreateOrganization = overwrite .AllowCreateOrganization .Value ()
618619 }
619620 if overwrite .EmailNotificationsPreference != nil {
620621 u .EmailNotificationsPreference = * overwrite .EmailNotificationsPreference
@@ -625,11 +626,11 @@ func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOve
625626 if overwrite .Theme != nil {
626627 u .Theme = * overwrite .Theme
627628 }
628- if ! overwrite .IsRestricted .IsNone () {
629- u .IsRestricted = overwrite .IsRestricted .IsTrue ()
629+ if overwrite .IsRestricted .Has () {
630+ u .IsRestricted = overwrite .IsRestricted .Value ()
630631 }
631- if ! overwrite .IsActive .IsNone () {
632- u .IsActive = overwrite .IsActive .IsTrue ()
632+ if overwrite .IsActive .Has () {
633+ u .IsActive = overwrite .IsActive .Value ()
633634 }
634635 }
635636
0 commit comments