Move kind to string

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-11 10:18:59 +01:00
parent 764f61bfa7
commit e393411333
19 changed files with 52 additions and 238 deletions

View File

@@ -105,7 +105,7 @@ type (
Role coredata.MembershipRole
FullName string
AdditionalEmailAddresses mail.Addrs
Kind *coredata.MembershipProfileKind
Kind *string
Position *string
ContractStartDate **time.Time
ContractEndDate **time.Time
@@ -115,7 +115,7 @@ type (
ID gid.GID
FullName string
AdditionalEmailAddresses mail.Addrs
Kind *coredata.MembershipProfileKind
Kind *string
Position *string
ContractStartDate **time.Time
ContractEndDate **time.Time
@@ -209,7 +209,6 @@ func (cur *CreateUserRequest) Validate() error {
v := validator.New()
v.Check(cur.OrganizationID, "id", validator.Required(), validator.GID(coredata.OrganizationEntityType))
v.Check(cur.Kind, "kind", validator.OneOfSlice(coredata.MembershipProfileKinds()))
v.Check(cur.FullName, "full_name", validator.SafeTextNoNewLine(NameMaxLength))
v.CheckEach(cur.AdditionalEmailAddresses, "additional_email_addresses", func(index int, item any) {
v.Check(item, fmt.Sprintf("additional_email_addresses[%d]", index), validator.Required(), validator.NotEmpty())
@@ -225,7 +224,6 @@ func (upr *UpdateUserRequest) Validate() error {
v := validator.New()
v.Check(upr.ID, "id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
v.Check(upr.Kind, "kind", validator.OneOfSlice(coredata.MembershipProfileKinds()))
v.Check(upr.FullName, "full_name", validator.SafeTextNoNewLine(NameMaxLength))
v.CheckEach(upr.AdditionalEmailAddresses, "additional_email_addresses", func(index int, item any) {
v.Check(item, fmt.Sprintf("additional_email_addresses[%d]", index), validator.Required(), validator.NotEmpty())

View File

@@ -223,12 +223,12 @@ func (s *Service) CreateUser(
CreatedAt: now,
UpdatedAt: now,
}
if attrs.UserType != "" {
kind := coredata.MembershipProfileKind(attrs.UserType)
profile.Kind = &kind
}
if attrs.UserType != "" {
kind := attrs.UserType
profile.Kind = &kind
}
err = profile.Insert(ctx, tx)
err = profile.Insert(ctx, tx)
if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return scimerrors.ScimErrorUniqueness
@@ -268,11 +268,11 @@ func (s *Service) CreateUser(
profile.Division = ref.RefOrNil(attrs.Division)
profile.ManagerValue = ref.RefOrNil(attrs.ManagerValue)
profile.UpdatedAt = now
if attrs.UserType != "" {
kind := coredata.MembershipProfileKind(attrs.UserType)
profile.Kind = &kind
}
if err := profile.Update(ctx, tx, scope); err != nil {
if attrs.UserType != "" {
kind := attrs.UserType
profile.Kind = &kind
}
if err := profile.Update(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot update profile: %w", err)
}
}
@@ -524,14 +524,13 @@ func (s *Service) updateUser(
}
if attrs.UserType != nil {
if *attrs.UserType == "" {
profile.Kind = nil
} else {
kind := coredata.MembershipProfileKind(*attrs.UserType)
profile.Kind = &kind
}
profile.UpdatedAt = now
if *attrs.UserType == "" {
profile.Kind = nil
} else {
profile.Kind = attrs.UserType
}
profile.UpdatedAt = now
}
if attrs.NickName != nil {
if *attrs.NickName == "" {