From d4b039737ea0bdee39cbb1e16b92a7b2eda297d2 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Mon, 22 Dec 2025 11:57:50 +0100 Subject: [PATCH] Rename identity profile on membership profile Signed-off-by: Bryan Frimin --- pkg/coredata/entity_type_reg.go | 8 +- pkg/coredata/identity.go | 12 +- pkg/coredata/membership.go | 76 +- ...ntity_profile.go => membership_profile.go} | 85 +- pkg/coredata/migrations/20251222T102632Z.sql | 15 + pkg/iam/account_service.go | 128 +-- pkg/iam/auth_service.go | 37 +- pkg/iam/saml/service.go | 24 +- pkg/server/api/connect/v1/schema.graphql | 21 +- pkg/server/api/connect/v1/schema/schema.go | 930 ++++++------------ pkg/server/api/connect/v1/types/identity.go | 1 + .../api/connect/v1/types/identity_profile.go | 4 +- pkg/server/api/connect/v1/types/types.go | 34 +- pkg/server/api/connect/v1/v1_resolver.go | 42 +- pkg/server/api/console/v1/v1_resolver.go | 18 +- 15 files changed, 391 insertions(+), 1044 deletions(-) rename pkg/coredata/{identity_profile.go => membership_profile.go} (71%) create mode 100644 pkg/coredata/migrations/20251222T102632Z.sql diff --git a/pkg/coredata/entity_type_reg.go b/pkg/coredata/entity_type_reg.go index 35460d726..8055661b0 100644 --- a/pkg/coredata/entity_type_reg.go +++ b/pkg/coredata/entity_type_reg.go @@ -72,7 +72,7 @@ const ( RightsRequestEntityType uint16 = 48 StateOfApplicabilityEntityType uint16 = 49 StateOfApplicabilityControlEntityType uint16 = 50 - IdentityProfileEntityType uint16 = 51 + MembershipProfileEntityType uint16 = 51 ) type EntityInfo struct { @@ -285,9 +285,9 @@ var entityRegistry = map[uint16]EntityInfo{ Model: "StateOfApplicabilityControl", Table: "states_of_applicability_controls", }, - IdentityProfileEntityType: { - Model: "IdentityProfile", - Table: "iam_identity_profiles", + MembershipProfileEntityType: { + Model: "MembershipProfile", + Table: "iam_membership_profiles", }, } diff --git a/pkg/coredata/identity.go b/pkg/coredata/identity.go index ea11f7b11..9bba52a3c 100644 --- a/pkg/coredata/identity.go +++ b/pkg/coredata/identity.go @@ -34,6 +34,7 @@ type ( Identity struct { ID gid.GID `db:"id"` EmailAddress mail.Addr `db:"email_address"` + FullName string `db:"full_name"` HashedPassword []byte `db:"hashed_password"` EmailAddressVerified bool `db:"email_address_verified"` SAMLSubject *string `db:"saml_subject"` @@ -63,8 +64,10 @@ func (i *Identities) LoadByOrganizationID( SELECT id, email_address, + full_name, hashed_password, email_address_verified, + saml_subject, created_at, updated_at FROM @@ -139,6 +142,7 @@ func (i *Identity) LoadByEmail( SELECT id, email_address, + full_name, hashed_password, email_address_verified, saml_subject, @@ -182,6 +186,7 @@ func (i *Identity) LoadByID( SELECT id, email_address, + full_name, hashed_password, email_address_verified, saml_subject, @@ -221,10 +226,11 @@ func (i *Identity) Insert( ) error { q := ` INSERT INTO - identities (id, email_address, hashed_password, email_address_verified, saml_subject, created_at, updated_at) + identities (id, email_address, full_name, hashed_password, email_address_verified, saml_subject, created_at, updated_at) VALUES ( @identity_id, @email_address, + @full_name, @hashed_password, @email_address_verified, @saml_subject, @@ -236,6 +242,7 @@ VALUES ( args := pgx.StrictNamedArgs{ "identity_id": i.ID, "email_address": i.EmailAddress, + "full_name": i.FullName, "hashed_password": i.HashedPassword, "saml_subject": i.SAMLSubject, "created_at": i.CreatedAt, @@ -265,6 +272,7 @@ UPDATE identities SET email_address = @email_address, + full_name = @full_name, email_address_verified = @email_address_verified, saml_subject = @saml_subject, hashed_password = @hashed_password, @@ -276,6 +284,7 @@ WHERE args := pgx.StrictNamedArgs{ "identity_id": i.ID, "email_address": i.EmailAddress, + "full_name": i.FullName, "email_address_verified": i.EmailAddressVerified, "saml_subject": i.SAMLSubject, "updated_at": i.UpdatedAt, @@ -304,6 +313,7 @@ func (i *Identity) LoadBySAMLSubject( SELECT id, email_address, + full_name, hashed_password, email_address_verified, saml_subject, diff --git a/pkg/coredata/membership.go b/pkg/coredata/membership.go index 17fefba7a..8180ef6b6 100644 --- a/pkg/coredata/membership.go +++ b/pkg/coredata/membership.go @@ -81,13 +81,14 @@ SELECT mbr.identity_id, mbr.organization_id, mbr.role, - i.fullname AS full_name, + COALESCE(mp.full_name, i.full_name, '') as full_name, i.email_address, mbr.created_at, mbr.updated_at FROM mbr JOIN identities i ON mbr.identity_id = i.id +LEFT JOIN iam_membership_profiles mp ON mp.membership_id = mbr.id ` args := pgx.StrictNamedArgs{ @@ -189,7 +190,7 @@ SELECT mbr.identity_id, mbr.organization_id, mbr.role, - COALESCE(mp.full_name, dp.full_name, '') as full_name, + COALESCE(mp.full_name, i.full_name, '') as full_name, i.email_address, mbr.created_at, mbr.updated_at @@ -198,9 +199,7 @@ FROM JOIN identities i ON mbr.identity_id = i.id LEFT JOIN - iam_identity_profiles mp ON mp.membership_id = mbr.id -LEFT JOIN - iam_identity_profiles dp ON dp.identity_id = mbr.identity_id AND dp.membership_id IS NULL + iam_membership_profiles mp ON mp.membership_id = mbr.id ` query = fmt.Sprintf(query, scope.SQLFragment()) @@ -333,7 +332,7 @@ SELECT mbr.identity_id, mbr.organization_id, mbr.role, - COALESCE(mp.full_name, dp.full_name, '') as full_name, + COALESCE(mp.full_name, i.full_name, '') as full_name, i.email_address, mbr.created_at, mbr.updated_at @@ -342,9 +341,7 @@ FROM JOIN identities i ON mbr.identity_id = i.id LEFT JOIN - iam_identity_profiles mp ON mp.membership_id = mbr.id -LEFT JOIN - iam_identity_profiles dp ON dp.identity_id = mbr.identity_id AND dp.membership_id IS NULL + iam_membership_profiles mp ON mp.membership_id = mbr.id ` q = fmt.Sprintf(q, scope.SQLFragment()) @@ -463,7 +460,7 @@ SELECT mbr.identity_id, mbr.organization_id, mbr.role, - COALESCE(mp.full_name, dp.full_name, '') as full_name, + COALESCE(mp.full_name, i.full_name, '') as full_name, i.email_address, mbr.created_at, mbr.updated_at @@ -472,19 +469,18 @@ FROM JOIN identities i ON mbr.identity_id = i.id LEFT JOIN - iam_identity_profiles mp ON mp.membership_id = mbr.id -LEFT JOIN - iam_identity_profiles dp ON dp.identity_id = mbr.identity_id AND dp.membership_id IS NULL -ORDER BY - mbr.created_at DESC + iam_membership_profiles mp ON mp.membership_id = mbr.id +WHERE + %s ` - query = fmt.Sprintf(query, scope.SQLFragment()) + query = fmt.Sprintf(query, scope.SQLFragment(), cursor.SQLFragment()) args := pgx.StrictNamedArgs{ "identity_id": identityID, } maps.Copy(args, scope.SQLArguments()) + maps.Copy(args, cursor.SQLArguments()) rows, err := conn.Query(ctx, query, args) if err != nil { @@ -508,18 +504,24 @@ func (m *Memberships) LoadByOrganizationID( cursor *page.Cursor[MembershipOrderField], ) error { query := ` -WITH mbr AS ( +WITH membership_with_profile AS ( SELECT - id, - identity_id, - organization_id, - role, - created_at, - updated_at + m.id, + m.identity_id, + m.organization_id, + m.role, + COALESCE(mp.full_name, i.full_name, '') AS full_name, + i.email_address, + m.created_at, + m.updated_at FROM - iam_memberships + iam_memberships m + JOIN + identities i ON m.identity_id = i.id + LEFT JOIN + iam_membership_profiles mp ON mp.membership_id = m.id WHERE - organization_id = @organization_id + m.organization_id = @organization_id AND %s ) SELECT @@ -531,26 +533,10 @@ SELECT email_address, created_at, updated_at -FROM ( - SELECT - mbr.id, - mbr.identity_id, - mbr.organization_id, - mbr.role, - COALESCE(mp.full_name, dp.full_name, '') as full_name, - i.email_address, - mbr.created_at, - mbr.updated_at - FROM - mbr - JOIN - identities i ON mbr.identity_id = i.id - LEFT JOIN - iam_identity_profiles mp ON mp.membership_id = mbr.id - LEFT JOIN - iam_identity_profiles dp ON dp.identity_id = mbr.identity_id AND dp.membership_id IS NULL -) AS membership_with_identity -WHERE %s +FROM + membership_with_profile +WHERE + %s ` query = fmt.Sprintf(query, scope.SQLFragment(), cursor.SQLFragment()) diff --git a/pkg/coredata/identity_profile.go b/pkg/coredata/membership_profile.go similarity index 71% rename from pkg/coredata/identity_profile.go rename to pkg/coredata/membership_profile.go index 705934f7f..bec17a983 100644 --- a/pkg/coredata/identity_profile.go +++ b/pkg/coredata/membership_profile.go @@ -27,68 +27,16 @@ import ( ) type ( - IdentityProfile struct { + MembershipProfile struct { ID gid.GID `db:"id"` - IdentityID gid.GID `db:"identity_id"` - MembershipID *gid.GID `db:"membership_id"` + MembershipID gid.GID `db:"membership_id"` FullName string `db:"full_name"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } - - IdentityProfiles []*IdentityProfile ) -func (p *IdentityProfile) IsDefault() bool { - return p.MembershipID == nil -} - -// LoadDefaultByIdentityID loads the default profile for an identity (where membership_id is NULL) -func (p *IdentityProfile) LoadDefaultByIdentityID( - ctx context.Context, - conn pg.Conn, - identityID gid.GID, -) error { - q := ` -SELECT - id, - identity_id, - membership_id, - full_name, - created_at, - updated_at -FROM - iam_identity_profiles -WHERE - tenant_id IS NULL - AND identity_id = @identity_id - AND membership_id IS NULL -LIMIT 1; -` - - args := pgx.StrictNamedArgs{"identity_id": identityID} - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query default identity profile: %w", err) - } - - profile, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[IdentityProfile]) - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - return ErrResourceNotFound - } - - return fmt.Errorf("cannot collect default identity profile: %w", err) - } - - *p = profile - - return nil -} - -// LoadByMembershipID loads the profile for a specific membership -func (p *IdentityProfile) LoadByMembershipID( +func (p *MembershipProfile) LoadByMembershipID( ctx context.Context, conn pg.Conn, scope Scoper, @@ -97,13 +45,12 @@ func (p *IdentityProfile) LoadByMembershipID( q := ` SELECT id, - identity_id, membership_id, full_name, created_at, updated_at FROM - iam_identity_profiles + iam_membership_profiles WHERE %s AND membership_id = @membership_id @@ -120,7 +67,7 @@ LIMIT 1; return fmt.Errorf("cannot query identity profile: %w", err) } - profile, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[IdentityProfile]) + profile, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[MembershipProfile]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound @@ -134,7 +81,7 @@ LIMIT 1; return nil } -func (p *IdentityProfile) LoadByID( +func (p *MembershipProfile) LoadByID( ctx context.Context, conn pg.Conn, scope Scoper, @@ -143,13 +90,12 @@ func (p *IdentityProfile) LoadByID( q := ` SELECT id, - identity_id, membership_id, full_name, created_at, updated_at FROM - iam_identity_profiles + iam_membership_profiles WHERE %s AND id = @profile_id @@ -166,7 +112,7 @@ LIMIT 1; return fmt.Errorf("cannot query identity profile: %w", err) } - profile, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[IdentityProfile]) + profile, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[MembershipProfile]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound @@ -180,16 +126,15 @@ LIMIT 1; return nil } -func (p *IdentityProfile) Insert( +func (p *MembershipProfile) Insert( ctx context.Context, conn pg.Conn, ) error { q := ` INSERT INTO - iam_identity_profiles ( + iam_membership_profiles ( tenant_id, id, - identity_id, membership_id, full_name, created_at, @@ -198,7 +143,6 @@ INSERT INTO VALUES ( @tenant_id, @id, - @identity_id, @membership_id, @full_name, @created_at, @@ -209,7 +153,6 @@ VALUES ( args := pgx.StrictNamedArgs{ "tenant_id": p.ID.TenantID().String(), "id": p.ID, - "identity_id": p.IdentityID, "membership_id": p.MembershipID, "full_name": p.FullName, "created_at": p.CreatedAt, @@ -224,14 +167,14 @@ VALUES ( return nil } -func (p *IdentityProfile) Update( +func (p *MembershipProfile) Update( ctx context.Context, conn pg.Conn, scope Scoper, ) error { q := ` UPDATE - iam_identity_profiles + iam_membership_profiles SET full_name = @full_name, updated_at = @updated_at @@ -261,7 +204,7 @@ WHERE return nil } -func (p *IdentityProfile) Delete( +func (p *MembershipProfile) Delete( ctx context.Context, conn pg.Conn, scope Scoper, @@ -269,7 +212,7 @@ func (p *IdentityProfile) Delete( ) error { q := ` DELETE FROM - iam_identity_profiles + iam_membership_profiles WHERE id = @profile_id AND %s diff --git a/pkg/coredata/migrations/20251222T102632Z.sql b/pkg/coredata/migrations/20251222T102632Z.sql new file mode 100644 index 000000000..e4fe87382 --- /dev/null +++ b/pkg/coredata/migrations/20251222T102632Z.sql @@ -0,0 +1,15 @@ +ALTER TABLE identities ADD COLUMN full_name TEXT NOT NULL DEFAULT ''; + +UPDATE identities i +SET full_name = COALESCE( + (SELECT p.full_name FROM iam_identity_profiles p + WHERE p.identity_id = i.id AND p.membership_id IS NULL), + '' +); + +DELETE FROM iam_identity_profiles WHERE membership_id IS NULL; +DROP INDEX IF EXISTS idx_iam_identity_profiles_default; + +ALTER TABLE iam_identity_profiles DROP COLUMN identity_id; + +ALTER TABLE iam_identity_profiles RENAME TO iam_membership_profiles; \ No newline at end of file diff --git a/pkg/iam/account_service.go b/pkg/iam/account_service.go index c608b6a01..a3b20ae13 100644 --- a/pkg/iam/account_service.go +++ b/pkg/iam/account_service.go @@ -125,14 +125,9 @@ func (s AccountService) ChangeEmail(ctx context.Context, identityID gid.GID, req return fmt.Errorf("cannot update identity: %w", err) } - profile := &coredata.IdentityProfile{} - if err := profile.LoadDefaultByIdentityID(ctx, tx, identityID); err != nil { - return fmt.Errorf("cannot load default profile: %w", err) - } - subject, textBody, htmlBody, err := emails.RenderConfirmEmail( s.baseURL, - profile.FullName, + identity.FullName, confirmationUrl, ) if err != nil { @@ -140,7 +135,7 @@ func (s AccountService) ChangeEmail(ctx context.Context, identityID gid.GID, req } confirmationEmail := coredata.NewEmail( - profile.FullName, + identity.FullName, identity.EmailAddress, subject, textBody, @@ -720,10 +715,10 @@ func (s AccountService) ListOrganizations(ctx context.Context, identityID gid.GI return organizations, nil } -func (s AccountService) GetProfileForMembership(ctx context.Context, membershipID gid.GID) (*coredata.IdentityProfile, error) { +func (s AccountService) GetProfileForMembership(ctx context.Context, membershipID gid.GID) (*coredata.MembershipProfile, error) { var ( scope = coredata.NewScopeFromObjectID(membershipID) - profile = &coredata.IdentityProfile{} + profile = &coredata.MembershipProfile{} ) err := s.pg.WithConn( @@ -758,118 +753,3 @@ func (s AccountService) GetProfileForMembership(ctx context.Context, membershipI return profile, nil } - -func (s AccountService) GetDefaultProfile(ctx context.Context, identityID gid.GID) (*coredata.IdentityProfile, error) { - var profile = &coredata.IdentityProfile{} - - err := s.pg.WithConn( - ctx, - func(conn pg.Conn) error { - err := profile.LoadDefaultByIdentityID(ctx, conn, identityID) - if err != nil { - if err == coredata.ErrResourceNotFound { - return NewProfileNotFoundError(identityID) - } - - return fmt.Errorf("cannot load default profile: %w", err) - } - - return nil - }, - ) - - if err != nil { - return nil, err - } - - return profile, nil -} - -type UpdateIdentityProfileRequest struct { - MembershipID gid.GID - FullName *string -} - -func (s AccountService) UpdateIdentityProfile( - ctx context.Context, - identityID gid.GID, - req *UpdateIdentityProfileRequest, -) (*coredata.IdentityProfile, error) { - // var ( - // scope = coredata.NewScopeFromObjectID(req.MembershipID) - // profile = &coredata.IdentityProfile{} - // ) - - // err := s.pg.WithTx( - // ctx, - // func(tx pg.Conn) error { - // // First verify the membership belongs to the identity - // membership := &coredata.Membership{} - // err := membership.LoadByID(ctx, tx, scope, req.MembershipID) - // if err != nil { - // if err == coredata.ErrResourceNotFound { - // return NewMembershipNotFoundError(req.MembershipID) - // } - - // return fmt.Errorf("cannot load membership: %w", err) - // } - - // if membership.IdentityID != identityID { - // return NewMembershipNotFoundError(req.MembershipID) - // } - - // // Try to load existing membership profile - // err = profile.LoadByMembershipID(ctx, tx, scope, req.MembershipID) - // if err != nil && err != coredata.ErrResourceNotFound { - // return fmt.Errorf("cannot load identity profile: %w", err) - // } - - // now := time.Now() - - // if err == coredata.ErrResourceNotFound { - // // Create new membership profile, optionally inheriting from default - // tenantID := req.MembershipID.TenantID() - // membershipID := req.MembershipID - - // // Try to get default profile to inherit FullName - // defaultProfile := &coredata.IdentityProfile{} - // defaultFullName := "" - // if loadErr := defaultProfile.LoadDefaultByIdentityID(ctx, tx, identityID); loadErr == nil { - // defaultFullName = defaultProfile.FullName - // } - - // tenantIDStr := tenantID.String() - // profile = &coredata.IdentityProfile{ - // ID: gid.New(tenantID, coredata.IdentityProfileEntityType), - // TenantID: &tenantIDStr, - // IdentityID: identityID, - // MembershipID: &membershipID, - // FullName: defaultFullName, - // CreatedAt: now, - // UpdatedAt: now, - // } - // } - - // // Apply updates - // if req.FullName != nil { - // profile.FullName = *req.FullName - // } - // profile.UpdatedAt = now - - // // Upsert the membership profile - // err = profile.UpsertMembership(ctx, tx) - // if err != nil { - // return fmt.Errorf("cannot upsert identity profile: %w", err) - // } - - // return nil - // }, - // ) - - // if err != nil { - // return nil, err - // } - - // return profile, nil - return nil, nil -} diff --git a/pkg/iam/auth_service.go b/pkg/iam/auth_service.go index 9f5eb56ba..c4f8481e4 100644 --- a/pkg/iam/auth_service.go +++ b/pkg/iam/auth_service.go @@ -156,6 +156,7 @@ func (s *AuthService) CreateIdentityFromInvitation( identity = &coredata.Identity{ ID: gid.New(gid.NilTenant, coredata.IdentityEntityType), EmailAddress: invitation.Email, + FullName: invitation.FullName, HashedPassword: hashedPassword, EmailAddressVerified: true, CreatedAt: now, @@ -171,19 +172,6 @@ func (s *AuthService) CreateIdentityFromInvitation( return fmt.Errorf("cannot insert identity: %w", err) } - defaultProfile := &coredata.IdentityProfile{ - ID: gid.New(gid.NilTenant, coredata.IdentityProfileEntityType), - IdentityID: identity.ID, - FullName: invitation.FullName, - CreatedAt: now, - UpdatedAt: now, - } - - err = defaultProfile.Insert(ctx, tx) - if err != nil { - return fmt.Errorf("cannot insert default profile: %w", err) - } - session = coredata.NewRootSession(identity.ID, coredata.AuthMethodPassword, s.sessionDuration) err = session.Insert(ctx, tx) if err != nil { @@ -285,14 +273,9 @@ func (s AuthService) SendPasswordResetInstructionByEmail( return fmt.Errorf("cannot load identity: %w", err) } - profile := &coredata.IdentityProfile{} - if err := profile.LoadDefaultByIdentityID(ctx, tx, identity.ID); err != nil { - return fmt.Errorf("cannot load default profile: %w", err) - } - subject, textBody, htmlBody, err := emails.RenderPasswordReset( s.baseURL, - profile.FullName, + identity.FullName, resetPasswordUrl, ) if err != nil { @@ -300,7 +283,7 @@ func (s AuthService) SendPasswordResetInstructionByEmail( } passwordResetEmail := coredata.NewEmail( - profile.FullName, + identity.FullName, identity.EmailAddress, subject, textBody, @@ -340,20 +323,13 @@ func (s AuthService) CreateIdentityWithPassword( identity = &coredata.Identity{ ID: gid.New(gid.NilTenant, coredata.IdentityEntityType), EmailAddress: req.Email, + FullName: req.FullName, HashedPassword: hashedPassword, EmailAddressVerified: false, CreatedAt: now, UpdatedAt: now, } - defaultProfile = &coredata.IdentityProfile{ - ID: gid.New(gid.NilTenant, coredata.IdentityProfileEntityType), - IdentityID: identity.ID, - FullName: req.FullName, - CreatedAt: now, - UpdatedAt: now, - } - session = coredata.NewRootSession(identity.ID, coredata.AuthMethodPassword, 24*time.Hour*7) ) @@ -409,11 +385,6 @@ func (s AuthService) CreateIdentityWithPassword( return fmt.Errorf("cannot insert identity: %w", err) } - err = defaultProfile.Insert(ctx, tx) - if err != nil { - return fmt.Errorf("cannot insert default profile: %w", err) - } - if err := confirmationEmail.Insert(ctx, tx); err != nil { return fmt.Errorf("cannot insert email: %w", err) } diff --git a/pkg/iam/saml/service.go b/pkg/iam/saml/service.go index c01be801f..696eac955 100644 --- a/pkg/iam/saml/service.go +++ b/pkg/iam/saml/service.go @@ -258,6 +258,7 @@ func (s *Service) HandleAssertion( *identity = coredata.Identity{ ID: gid.New(gid.NilTenant, coredata.IdentityEntityType), EmailAddress: email, + FullName: fullname, HashedPassword: nil, EmailAddressVerified: true, CreatedAt: now, @@ -268,24 +269,12 @@ func (s *Service) HandleAssertion( if err != nil { return fmt.Errorf("cannot insert identity: %w", err) } - - defaultProfile := &coredata.IdentityProfile{ - ID: gid.New(gid.NilTenant, coredata.IdentityProfileEntityType), - IdentityID: identity.ID, - FullName: fullname, - CreatedAt: now, - UpdatedAt: now, - } - - err = defaultProfile.Insert(ctx, tx) - if err != nil { - return fmt.Errorf("cannot insert default profile: %w", err) - } } else if err != nil { return fmt.Errorf("cannot load identity: %w", err) } else { identity.SAMLSubject = &assertion.Subject.NameID.Value identity.EmailAddress = email + identity.FullName = fullname identity.EmailAddressVerified = true identity.UpdatedAt = now @@ -316,10 +305,9 @@ func (s *Service) HandleAssertion( return fmt.Errorf("cannot insert membership: %w", err) } - membershipProfile := &coredata.IdentityProfile{ - ID: gid.New(membership.ID.TenantID(), coredata.IdentityProfileEntityType), - IdentityID: identity.ID, - MembershipID: &membership.ID, + membershipProfile := &coredata.MembershipProfile{ + ID: gid.New(membership.ID.TenantID(), coredata.MembershipProfileEntityType), + MembershipID: membership.ID, FullName: fullname, CreatedAt: now, UpdatedAt: now, @@ -341,7 +329,7 @@ func (s *Service) HandleAssertion( } } - memberProfile := &coredata.IdentityProfile{} + memberProfile := &coredata.MembershipProfile{} err = memberProfile.LoadByMembershipID(ctx, tx, coredata.NewNoScope(), membership.ID) if err != nil { return fmt.Errorf("cannot load membership profile: %w", err) diff --git a/pkg/server/api/connect/v1/schema.graphql b/pkg/server/api/connect/v1/schema.graphql index ff0a0f4b5..5460caace 100644 --- a/pkg/server/api/connect/v1/schema.graphql +++ b/pkg/server/api/connect/v1/schema.graphql @@ -79,10 +79,6 @@ type Mutation { input: AssumeOrganizationSessionInput! ): AssumeOrganizationSessionPayload @session(required: PRESENT) - updateIdentityProfile( - input: UpdateIdentityProfileInput! - ): UpdateIdentityProfilePayload @session(required: PRESENT) - revokeSession(input: RevokeSessionInput!): RevokeSessionPayload! @session(required: PRESENT) revokeAllSessions: RevokeAllSessionsPayload @session(required: PRESENT) @@ -134,12 +130,11 @@ type Mutation { type Identity implements Node { id: ID! email: EmailAddr! + fullName: String! emailVerified: Boolean! createdAt: Datetime! updatedAt: Datetime! - defaultProfile: IdentityProfile @goField(forceResolver: true) @isViewer - memberships( first: Int after: CursorKey @@ -172,10 +167,9 @@ type Identity implements Node { ): PersonalAPIKeyConnection @goField(forceResolver: true) @isViewer } -type IdentityProfile implements Node { +type MembershipProfile implements Node { id: ID! fullName: String! - identity: Identity! createdAt: Datetime! updatedAt: Datetime! } @@ -233,7 +227,7 @@ type Membership implements Node { id: ID! createdAt: Datetime! identity: Identity @goField(forceResolver: true) - profile: IdentityProfile @goField(forceResolver: true) @isViewer + profile: MembershipProfile @goField(forceResolver: true) @isViewer organization: Organization @goField(forceResolver: true) role: MembershipRole! permissions: [Permission!]! @@ -558,11 +552,6 @@ input AssumeOrganizationSessionInput { organizationId: ID! } -input UpdateIdentityProfileInput { - membershipId: ID! - fullName: String -} - input RevokeSessionInput { sessionId: ID! } @@ -725,10 +714,6 @@ type DeactivateAccountPayload { success: Boolean! } -type UpdateIdentityProfilePayload { - profile: IdentityProfile -} - type RevokeSessionPayload { success: Boolean! } diff --git a/pkg/server/api/connect/v1/schema/schema.go b/pkg/server/api/connect/v1/schema/schema.go index 557220d2b..75b29ee00 100644 --- a/pkg/server/api/connect/v1/schema/schema.go +++ b/pkg/server/api/connect/v1/schema/schema.go @@ -129,9 +129,9 @@ type ComplexityRoot struct { Identity struct { CreatedAt func(childComplexity int) int - DefaultProfile func(childComplexity int) int Email func(childComplexity int) int EmailVerified func(childComplexity int) int + FullName func(childComplexity int) int ID func(childComplexity int) int Memberships func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MembershipOrderBy) int PendingInvitations func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.InvitationOrderBy) int @@ -140,14 +140,6 @@ type ComplexityRoot struct { UpdatedAt func(childComplexity int) int } - IdentityProfile struct { - CreatedAt func(childComplexity int) int - FullName func(childComplexity int) int - ID func(childComplexity int) int - Identity func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - Invitation struct { AcceptedAt func(childComplexity int) int CreatedAt func(childComplexity int) int @@ -196,6 +188,13 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + MembershipProfile struct { + CreatedAt func(childComplexity int) int + FullName func(childComplexity int) int + ID func(childComplexity int) int + UpdatedAt func(childComplexity int) int + } + Mutation struct { AcceptInvitation func(childComplexity int, input types.AcceptInvitationInput) int AssumeOrganizationSession func(childComplexity int, input types.AssumeOrganizationSessionInput) int @@ -219,7 +218,6 @@ type ComplexityRoot struct { SignOut func(childComplexity int) int SignUp func(childComplexity int, input types.SignUpInput) int SignUpFromInvitation func(childComplexity int, input types.SignUpFromInvitationInput) int - UpdateIdentityProfile func(childComplexity int, input types.UpdateIdentityProfileInput) int UpdateOrganization func(childComplexity int, input types.UpdateOrganizationInput) int UpdatePersonalAPIKey func(childComplexity int, input types.UpdatePersonalAPIKeyInput) int UpdateSAMLConfiguration func(childComplexity int, input types.UpdateSAMLConfigurationInput) int @@ -406,10 +404,6 @@ type ComplexityRoot struct { Identity func(childComplexity int) int } - UpdateIdentityProfilePayload struct { - Profile func(childComplexity int) int - } - UpdateOrganizationPayload struct { Organization func(childComplexity int) int } @@ -428,7 +422,6 @@ type ComplexityRoot struct { } type IdentityResolver interface { - DefaultProfile(ctx context.Context, obj *types.Identity) (*types.IdentityProfile, error) Memberships(ctx context.Context, obj *types.Identity, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MembershipOrderBy) (*types.MembershipConnection, error) PendingInvitations(ctx context.Context, obj *types.Identity, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.InvitationOrderBy) (*types.InvitationConnection, error) Sessions(ctx context.Context, obj *types.Identity, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.SessionOrder) (*types.SessionConnection, error) @@ -442,7 +435,7 @@ type InvitationConnectionResolver interface { } type MembershipResolver interface { Identity(ctx context.Context, obj *types.Membership) (*types.Identity, error) - Profile(ctx context.Context, obj *types.Membership) (*types.IdentityProfile, error) + Profile(ctx context.Context, obj *types.Membership) (*types.MembershipProfile, error) Organization(ctx context.Context, obj *types.Membership) (*types.Organization, error) LastSession(ctx context.Context, obj *types.Membership) (*types.Session, error) @@ -461,7 +454,6 @@ type MutationResolver interface { ChangePassword(ctx context.Context, input types.ChangePasswordInput) (*types.ChangePasswordPayload, error) ChangeEmail(ctx context.Context, input types.ChangeEmailInput) (*types.ChangeEmailPayload, error) AssumeOrganizationSession(ctx context.Context, input types.AssumeOrganizationSessionInput) (*types.AssumeOrganizationSessionPayload, error) - UpdateIdentityProfile(ctx context.Context, input types.UpdateIdentityProfileInput) (*types.UpdateIdentityProfilePayload, error) RevokeSession(ctx context.Context, input types.RevokeSessionInput) (*types.RevokeSessionPayload, error) RevokeAllSessions(ctx context.Context) (*types.RevokeAllSessionsPayload, error) CreatePersonalAPIKey(ctx context.Context, input types.CreatePersonalAPIKeyInput) (*types.CreatePersonalAPIKeyPayload, error) @@ -658,12 +650,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.complexity.Identity.CreatedAt(childComplexity), true - case "Identity.defaultProfile": - if e.complexity.Identity.DefaultProfile == nil { - break - } - - return e.complexity.Identity.DefaultProfile(childComplexity), true case "Identity.email": if e.complexity.Identity.Email == nil { break @@ -676,6 +662,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.complexity.Identity.EmailVerified(childComplexity), true + case "Identity.fullName": + if e.complexity.Identity.FullName == nil { + break + } + + return e.complexity.Identity.FullName(childComplexity), true case "Identity.id": if e.complexity.Identity.ID == nil { break @@ -733,37 +725,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Identity.UpdatedAt(childComplexity), true - case "IdentityProfile.createdAt": - if e.complexity.IdentityProfile.CreatedAt == nil { - break - } - - return e.complexity.IdentityProfile.CreatedAt(childComplexity), true - case "IdentityProfile.fullName": - if e.complexity.IdentityProfile.FullName == nil { - break - } - - return e.complexity.IdentityProfile.FullName(childComplexity), true - case "IdentityProfile.id": - if e.complexity.IdentityProfile.ID == nil { - break - } - - return e.complexity.IdentityProfile.ID(childComplexity), true - case "IdentityProfile.identity": - if e.complexity.IdentityProfile.Identity == nil { - break - } - - return e.complexity.IdentityProfile.Identity(childComplexity), true - case "IdentityProfile.updatedAt": - if e.complexity.IdentityProfile.UpdatedAt == nil { - break - } - - return e.complexity.IdentityProfile.UpdatedAt(childComplexity), true - case "Invitation.acceptedAt": if e.complexity.Invitation.AcceptedAt == nil { break @@ -933,6 +894,31 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.MembershipEdge.Node(childComplexity), true + case "MembershipProfile.createdAt": + if e.complexity.MembershipProfile.CreatedAt == nil { + break + } + + return e.complexity.MembershipProfile.CreatedAt(childComplexity), true + case "MembershipProfile.fullName": + if e.complexity.MembershipProfile.FullName == nil { + break + } + + return e.complexity.MembershipProfile.FullName(childComplexity), true + case "MembershipProfile.id": + if e.complexity.MembershipProfile.ID == nil { + break + } + + return e.complexity.MembershipProfile.ID(childComplexity), true + case "MembershipProfile.updatedAt": + if e.complexity.MembershipProfile.UpdatedAt == nil { + break + } + + return e.complexity.MembershipProfile.UpdatedAt(childComplexity), true + case "Mutation.acceptInvitation": if e.complexity.Mutation.AcceptInvitation == nil { break @@ -1165,17 +1151,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.complexity.Mutation.SignUpFromInvitation(childComplexity, args["input"].(types.SignUpFromInvitationInput)), true - case "Mutation.updateIdentityProfile": - if e.complexity.Mutation.UpdateIdentityProfile == nil { - break - } - - args, err := ec.field_Mutation_updateIdentityProfile_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.UpdateIdentityProfile(childComplexity, args["input"].(types.UpdateIdentityProfileInput)), true case "Mutation.updateOrganization": if e.complexity.Mutation.UpdateOrganization == nil { break @@ -1850,13 +1825,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.SignUpPayload.Identity(childComplexity), true - case "UpdateIdentityProfilePayload.profile": - if e.complexity.UpdateIdentityProfilePayload.Profile == nil { - break - } - - return e.complexity.UpdateIdentityProfilePayload.Profile(childComplexity), true - case "UpdateOrganizationPayload.organization": if e.complexity.UpdateOrganizationPayload.Organization == nil { break @@ -1917,7 +1885,6 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputSignInInput, ec.unmarshalInputSignUpFromInvitationInput, ec.unmarshalInputSignUpInput, - ec.unmarshalInputUpdateIdentityProfileInput, ec.unmarshalInputUpdateOrganizationInput, ec.unmarshalInputUpdatePersonalAPIKeyInput, ec.unmarshalInputUpdateSAMLConfigurationInput, @@ -2100,10 +2067,6 @@ type Mutation { input: AssumeOrganizationSessionInput! ): AssumeOrganizationSessionPayload @session(required: PRESENT) - updateIdentityProfile( - input: UpdateIdentityProfileInput! - ): UpdateIdentityProfilePayload @session(required: PRESENT) - revokeSession(input: RevokeSessionInput!): RevokeSessionPayload! @session(required: PRESENT) revokeAllSessions: RevokeAllSessionsPayload @session(required: PRESENT) @@ -2155,12 +2118,11 @@ type Mutation { type Identity implements Node { id: ID! email: EmailAddr! + fullName: String! emailVerified: Boolean! createdAt: Datetime! updatedAt: Datetime! - defaultProfile: IdentityProfile @goField(forceResolver: true) @isViewer - memberships( first: Int after: CursorKey @@ -2193,10 +2155,9 @@ type Identity implements Node { ): PersonalAPIKeyConnection @goField(forceResolver: true) @isViewer } -type IdentityProfile implements Node { +type MembershipProfile implements Node { id: ID! fullName: String! - identity: Identity! createdAt: Datetime! updatedAt: Datetime! } @@ -2254,7 +2215,7 @@ type Membership implements Node { id: ID! createdAt: Datetime! identity: Identity @goField(forceResolver: true) - profile: IdentityProfile @goField(forceResolver: true) @isViewer + profile: MembershipProfile @goField(forceResolver: true) @isViewer organization: Organization @goField(forceResolver: true) role: MembershipRole! permissions: [Permission!]! @@ -2579,11 +2540,6 @@ input AssumeOrganizationSessionInput { organizationId: ID! } -input UpdateIdentityProfileInput { - membershipId: ID! - fullName: String -} - input RevokeSessionInput { sessionId: ID! } @@ -2746,10 +2702,6 @@ type DeactivateAccountPayload { success: Boolean! } -type UpdateIdentityProfilePayload { - profile: IdentityProfile -} - type RevokeSessionPayload { success: Boolean! } @@ -3173,17 +3125,6 @@ func (ec *executionContext) field_Mutation_signUp_args(ctx context.Context, rawA return args, nil } -func (ec *executionContext) field_Mutation_updateIdentityProfile_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNUpdateIdentityProfileInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐUpdateIdentityProfileInput) - if err != nil { - return nil, err - } - args["input"] = arg0 - return args, nil -} - func (ec *executionContext) field_Mutation_updateOrganization_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4094,6 +4035,35 @@ func (ec *executionContext) fieldContext_Identity_email(_ context.Context, field return fc, nil } +func (ec *executionContext) _Identity_fullName(ctx context.Context, field graphql.CollectedField, obj *types.Identity) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Identity_fullName, + func(ctx context.Context) (any, error) { + return obj.FullName, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Identity_fullName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Identity", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Identity_emailVerified(ctx context.Context, field graphql.CollectedField, obj *types.Identity) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -4181,60 +4151,6 @@ func (ec *executionContext) fieldContext_Identity_updatedAt(_ context.Context, f return fc, nil } -func (ec *executionContext) _Identity_defaultProfile(ctx context.Context, field graphql.CollectedField, obj *types.Identity) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Identity_defaultProfile, - func(ctx context.Context) (any, error) { - return ec.resolvers.Identity().DefaultProfile(ctx, obj) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsViewer == nil { - var zeroVal *types.IdentityProfile - return zeroVal, errors.New("directive isViewer is not implemented") - } - return ec.directives.IsViewer(ctx, obj, directive0) - } - - next = directive1 - return next - }, - ec.marshalOIdentityProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐIdentityProfile, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_Identity_defaultProfile(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Identity", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_IdentityProfile_id(ctx, field) - case "fullName": - return ec.fieldContext_IdentityProfile_fullName(ctx, field) - case "identity": - return ec.fieldContext_IdentityProfile_identity(ctx, field) - case "createdAt": - return ec.fieldContext_IdentityProfile_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_IdentityProfile_updatedAt(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type IdentityProfile", field.Name) - }, - } - return fc, nil -} - func (ec *executionContext) _Identity_memberships(ctx context.Context, field graphql.CollectedField, obj *types.Identity) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -4483,173 +4399,6 @@ func (ec *executionContext) fieldContext_Identity_personalAPIKeys(ctx context.Co return fc, nil } -func (ec *executionContext) _IdentityProfile_id(ctx context.Context, field graphql.CollectedField, obj *types.IdentityProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_IdentityProfile_id, - func(ctx context.Context) (any, error) { - return obj.ID, nil - }, - nil, - ec.marshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_IdentityProfile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IdentityProfile", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _IdentityProfile_fullName(ctx context.Context, field graphql.CollectedField, obj *types.IdentityProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_IdentityProfile_fullName, - func(ctx context.Context) (any, error) { - return obj.FullName, nil - }, - nil, - ec.marshalNString2string, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_IdentityProfile_fullName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IdentityProfile", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _IdentityProfile_identity(ctx context.Context, field graphql.CollectedField, obj *types.IdentityProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_IdentityProfile_identity, - func(ctx context.Context) (any, error) { - return obj.Identity, nil - }, - nil, - ec.marshalNIdentity2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐIdentity, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_IdentityProfile_identity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IdentityProfile", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Identity_id(ctx, field) - case "email": - return ec.fieldContext_Identity_email(ctx, field) - case "emailVerified": - return ec.fieldContext_Identity_emailVerified(ctx, field) - case "createdAt": - return ec.fieldContext_Identity_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) - case "memberships": - return ec.fieldContext_Identity_memberships(ctx, field) - case "pendingInvitations": - return ec.fieldContext_Identity_pendingInvitations(ctx, field) - case "sessions": - return ec.fieldContext_Identity_sessions(ctx, field) - case "personalAPIKeys": - return ec.fieldContext_Identity_personalAPIKeys(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Identity", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _IdentityProfile_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.IdentityProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_IdentityProfile_createdAt, - func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil - }, - nil, - ec.marshalNDatetime2timeᚐTime, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_IdentityProfile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IdentityProfile", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _IdentityProfile_updatedAt(ctx context.Context, field graphql.CollectedField, obj *types.IdentityProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_IdentityProfile_updatedAt, - func(ctx context.Context) (any, error) { - return obj.UpdatedAt, nil - }, - nil, - ec.marshalNDatetime2timeᚐTime, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_IdentityProfile_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IdentityProfile", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Datetime does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _Invitation_id(ctx context.Context, field graphql.CollectedField, obj *types.Invitation) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -5212,14 +4961,14 @@ func (ec *executionContext) fieldContext_Membership_identity(_ context.Context, return ec.fieldContext_Identity_id(ctx, field) case "email": return ec.fieldContext_Identity_email(ctx, field) + case "fullName": + return ec.fieldContext_Identity_fullName(ctx, field) case "emailVerified": return ec.fieldContext_Identity_emailVerified(ctx, field) case "createdAt": return ec.fieldContext_Identity_createdAt(ctx, field) case "updatedAt": return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) case "memberships": return ec.fieldContext_Identity_memberships(ctx, field) case "pendingInvitations": @@ -5249,7 +4998,7 @@ func (ec *executionContext) _Membership_profile(ctx context.Context, field graph directive1 := func(ctx context.Context) (any, error) { if ec.directives.IsViewer == nil { - var zeroVal *types.IdentityProfile + var zeroVal *types.MembershipProfile return zeroVal, errors.New("directive isViewer is not implemented") } return ec.directives.IsViewer(ctx, obj, directive0) @@ -5258,7 +5007,7 @@ func (ec *executionContext) _Membership_profile(ctx context.Context, field graph next = directive1 return next }, - ec.marshalOIdentityProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐIdentityProfile, + ec.marshalOMembershipProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐMembershipProfile, true, false, ) @@ -5273,17 +5022,15 @@ func (ec *executionContext) fieldContext_Membership_profile(_ context.Context, f Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_IdentityProfile_id(ctx, field) + return ec.fieldContext_MembershipProfile_id(ctx, field) case "fullName": - return ec.fieldContext_IdentityProfile_fullName(ctx, field) - case "identity": - return ec.fieldContext_IdentityProfile_identity(ctx, field) + return ec.fieldContext_MembershipProfile_fullName(ctx, field) case "createdAt": - return ec.fieldContext_IdentityProfile_createdAt(ctx, field) + return ec.fieldContext_MembershipProfile_createdAt(ctx, field) case "updatedAt": - return ec.fieldContext_IdentityProfile_updatedAt(ctx, field) + return ec.fieldContext_MembershipProfile_updatedAt(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type IdentityProfile", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MembershipProfile", field.Name) }, } return fc, nil @@ -5659,6 +5406,122 @@ func (ec *executionContext) fieldContext_MembershipEdge_cursor(_ context.Context return fc, nil } +func (ec *executionContext) _MembershipProfile_id(ctx context.Context, field graphql.CollectedField, obj *types.MembershipProfile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_MembershipProfile_id, + func(ctx context.Context) (any, error) { + return obj.ID, nil + }, + nil, + ec.marshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_MembershipProfile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MembershipProfile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MembershipProfile_fullName(ctx context.Context, field graphql.CollectedField, obj *types.MembershipProfile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_MembershipProfile_fullName, + func(ctx context.Context) (any, error) { + return obj.FullName, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_MembershipProfile_fullName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MembershipProfile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MembershipProfile_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.MembershipProfile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_MembershipProfile_createdAt, + func(ctx context.Context) (any, error) { + return obj.CreatedAt, nil + }, + nil, + ec.marshalNDatetime2timeᚐTime, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_MembershipProfile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MembershipProfile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Datetime does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MembershipProfile_updatedAt(ctx context.Context, field graphql.CollectedField, obj *types.MembershipProfile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_MembershipProfile_updatedAt, + func(ctx context.Context) (any, error) { + return obj.UpdatedAt, nil + }, + nil, + ec.marshalNDatetime2timeᚐTime, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_MembershipProfile_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MembershipProfile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Datetime does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Mutation_signIn(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -6279,69 +6142,6 @@ func (ec *executionContext) fieldContext_Mutation_assumeOrganizationSession(ctx return fc, nil } -func (ec *executionContext) _Mutation_updateIdentityProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Mutation_updateIdentityProfile, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateIdentityProfile(ctx, fc.Args["input"].(types.UpdateIdentityProfileInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - required, err := ec.unmarshalNSessionRequirement2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐSessionRequirement(ctx, "PRESENT") - if err != nil { - var zeroVal *types.UpdateIdentityProfilePayload - return zeroVal, err - } - if ec.directives.Session == nil { - var zeroVal *types.UpdateIdentityProfilePayload - return zeroVal, errors.New("directive session is not implemented") - } - return ec.directives.Session(ctx, nil, directive0, required) - } - - next = directive1 - return next - }, - ec.marshalOUpdateIdentityProfilePayload2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐUpdateIdentityProfilePayload, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_Mutation_updateIdentityProfile(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "profile": - return ec.fieldContext_UpdateIdentityProfilePayload_profile(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UpdateIdentityProfilePayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateIdentityProfile_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Mutation_revokeSession(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -8881,14 +8681,14 @@ func (ec *executionContext) fieldContext_Query_viewer(_ context.Context, field g return ec.fieldContext_Identity_id(ctx, field) case "email": return ec.fieldContext_Identity_email(ctx, field) + case "fullName": + return ec.fieldContext_Identity_fullName(ctx, field) case "emailVerified": return ec.fieldContext_Identity_emailVerified(ctx, field) case "createdAt": return ec.fieldContext_Identity_createdAt(ctx, field) case "updatedAt": return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) case "memberships": return ec.fieldContext_Identity_memberships(ctx, field) case "pendingInvitations": @@ -10199,14 +9999,14 @@ func (ec *executionContext) fieldContext_Session_identity(_ context.Context, fie return ec.fieldContext_Identity_id(ctx, field) case "email": return ec.fieldContext_Identity_email(ctx, field) + case "fullName": + return ec.fieldContext_Identity_fullName(ctx, field) case "emailVerified": return ec.fieldContext_Identity_emailVerified(ctx, field) case "createdAt": return ec.fieldContext_Identity_createdAt(ctx, field) case "updatedAt": return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) case "memberships": return ec.fieldContext_Identity_memberships(ctx, field) case "pendingInvitations": @@ -10572,14 +10372,14 @@ func (ec *executionContext) fieldContext_SignInPayload_identity(_ context.Contex return ec.fieldContext_Identity_id(ctx, field) case "email": return ec.fieldContext_Identity_email(ctx, field) + case "fullName": + return ec.fieldContext_Identity_fullName(ctx, field) case "emailVerified": return ec.fieldContext_Identity_emailVerified(ctx, field) case "createdAt": return ec.fieldContext_Identity_createdAt(ctx, field) case "updatedAt": return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) case "memberships": return ec.fieldContext_Identity_memberships(ctx, field) case "pendingInvitations": @@ -10697,14 +10497,14 @@ func (ec *executionContext) fieldContext_SignUpFromInvitationPayload_identity(_ return ec.fieldContext_Identity_id(ctx, field) case "email": return ec.fieldContext_Identity_email(ctx, field) + case "fullName": + return ec.fieldContext_Identity_fullName(ctx, field) case "emailVerified": return ec.fieldContext_Identity_emailVerified(ctx, field) case "createdAt": return ec.fieldContext_Identity_createdAt(ctx, field) case "updatedAt": return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) case "memberships": return ec.fieldContext_Identity_memberships(ctx, field) case "pendingInvitations": @@ -10748,14 +10548,14 @@ func (ec *executionContext) fieldContext_SignUpPayload_identity(_ context.Contex return ec.fieldContext_Identity_id(ctx, field) case "email": return ec.fieldContext_Identity_email(ctx, field) + case "fullName": + return ec.fieldContext_Identity_fullName(ctx, field) case "emailVerified": return ec.fieldContext_Identity_emailVerified(ctx, field) case "createdAt": return ec.fieldContext_Identity_createdAt(ctx, field) case "updatedAt": return ec.fieldContext_Identity_updatedAt(ctx, field) - case "defaultProfile": - return ec.fieldContext_Identity_defaultProfile(ctx, field) case "memberships": return ec.fieldContext_Identity_memberships(ctx, field) case "pendingInvitations": @@ -10771,47 +10571,6 @@ func (ec *executionContext) fieldContext_SignUpPayload_identity(_ context.Contex return fc, nil } -func (ec *executionContext) _UpdateIdentityProfilePayload_profile(ctx context.Context, field graphql.CollectedField, obj *types.UpdateIdentityProfilePayload) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_UpdateIdentityProfilePayload_profile, - func(ctx context.Context) (any, error) { - return obj.Profile, nil - }, - nil, - ec.marshalOIdentityProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐIdentityProfile, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_UpdateIdentityProfilePayload_profile(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "UpdateIdentityProfilePayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_IdentityProfile_id(ctx, field) - case "fullName": - return ec.fieldContext_IdentityProfile_fullName(ctx, field) - case "identity": - return ec.fieldContext_IdentityProfile_identity(ctx, field) - case "createdAt": - return ec.fieldContext_IdentityProfile_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_IdentityProfile_updatedAt(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type IdentityProfile", field.Name) - }, - } - return fc, nil -} - func (ec *executionContext) _UpdateOrganizationPayload_organization(ctx context.Context, field graphql.CollectedField, obj *types.UpdateOrganizationPayload) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -13296,40 +13055,6 @@ func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj a return it, nil } -func (ec *executionContext) unmarshalInputUpdateIdentityProfileInput(ctx context.Context, obj any) (types.UpdateIdentityProfileInput, error) { - var it types.UpdateIdentityProfileInput - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"membershipId", "fullName"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "membershipId": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("membershipId")) - data, err := ec.unmarshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID(ctx, v) - if err != nil { - return it, err - } - it.MembershipID = data - case "fullName": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fullName")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.FullName = data - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputUpdateOrganizationInput(ctx context.Context, obj any) (types.UpdateOrganizationInput, error) { var it types.UpdateOrganizationInput asMap := map[string]any{} @@ -13623,6 +13348,13 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Organization(ctx, sel, obj) + case types.MembershipProfile: + return ec._MembershipProfile(ctx, sel, &obj) + case *types.MembershipProfile: + if obj == nil { + return graphql.Null + } + return ec._MembershipProfile(ctx, sel, obj) case types.Membership: return ec._Membership(ctx, sel, &obj) case *types.Membership: @@ -13637,13 +13369,6 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Invitation(ctx, sel, obj) - case types.IdentityProfile: - return ec._IdentityProfile(ctx, sel, &obj) - case *types.IdentityProfile: - if obj == nil { - return graphql.Null - } - return ec._IdentityProfile(ctx, sel, obj) case types.Identity: return ec._Identity(ctx, sel, &obj) case *types.Identity: @@ -14249,6 +13974,11 @@ func (ec *executionContext) _Identity(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "fullName": + out.Values[i] = ec._Identity_fullName(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "emailVerified": out.Values[i] = ec._Identity_emailVerified(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -14264,39 +13994,6 @@ func (ec *executionContext) _Identity(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "defaultProfile": - field := field - - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Identity_defaultProfile(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "memberships": field := field @@ -14452,65 +14149,6 @@ func (ec *executionContext) _Identity(ctx context.Context, sel ast.SelectionSet, return out } -var identityProfileImplementors = []string{"IdentityProfile", "Node"} - -func (ec *executionContext) _IdentityProfile(ctx context.Context, sel ast.SelectionSet, obj *types.IdentityProfile) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, identityProfileImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("IdentityProfile") - case "id": - out.Values[i] = ec._IdentityProfile_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "fullName": - out.Values[i] = ec._IdentityProfile_fullName(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "identity": - out.Values[i] = ec._IdentityProfile_identity(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createdAt": - out.Values[i] = ec._IdentityProfile_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._IdentityProfile_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var invitationImplementors = []string{"Invitation", "Node"} func (ec *executionContext) _Invitation(ctx context.Context, sel ast.SelectionSet, obj *types.Invitation) graphql.Marshaler { @@ -15077,6 +14715,60 @@ func (ec *executionContext) _MembershipEdge(ctx context.Context, sel ast.Selecti return out } +var membershipProfileImplementors = []string{"MembershipProfile", "Node"} + +func (ec *executionContext) _MembershipProfile(ctx context.Context, sel ast.SelectionSet, obj *types.MembershipProfile) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, membershipProfileImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MembershipProfile") + case "id": + out.Values[i] = ec._MembershipProfile_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "fullName": + out.Values[i] = ec._MembershipProfile_fullName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._MembershipProfile_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updatedAt": + out.Values[i] = ec._MembershipProfile_updatedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -15136,10 +14828,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_assumeOrganizationSession(ctx, field) }) - case "updateIdentityProfile": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateIdentityProfile(ctx, field) - }) case "revokeSession": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_revokeSession(ctx, field) @@ -16930,42 +16618,6 @@ func (ec *executionContext) _SignUpPayload(ctx context.Context, sel ast.Selectio return out } -var updateIdentityProfilePayloadImplementors = []string{"UpdateIdentityProfilePayload"} - -func (ec *executionContext) _UpdateIdentityProfilePayload(ctx context.Context, sel ast.SelectionSet, obj *types.UpdateIdentityProfilePayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, updateIdentityProfilePayloadImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("UpdateIdentityProfilePayload") - case "profile": - out.Values[i] = ec._UpdateIdentityProfilePayload_profile(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var updateOrganizationPayloadImplementors = []string{"UpdateOrganizationPayload"} func (ec *executionContext) _UpdateOrganizationPayload(ctx context.Context, sel ast.SelectionSet, obj *types.UpdateOrganizationPayload) graphql.Marshaler { @@ -17761,16 +17413,6 @@ func (ec *executionContext) marshalNID2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋgid return ret } -func (ec *executionContext) marshalNIdentity2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐIdentity(ctx context.Context, sel ast.SelectionSet, v *types.Identity) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Identity(ctx, sel, v) -} - func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v any) (int, error) { res, err := graphql.UnmarshalInt(v) return res, graphql.ErrorOnPath(ctx, err) @@ -18680,11 +18322,6 @@ func (ec *executionContext) marshalNTokenScope2ᚕgoᚗproboᚗincᚋproboᚋpkg return ret } -func (ec *executionContext) unmarshalNUpdateIdentityProfileInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐUpdateIdentityProfileInput(ctx context.Context, v any) (types.UpdateIdentityProfileInput, error) { - res, err := ec.unmarshalInputUpdateIdentityProfileInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) unmarshalNUpdateOrganizationInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐUpdateOrganizationInput(ctx context.Context, v any) (types.UpdateOrganizationInput, error) { res, err := ec.unmarshalInputUpdateOrganizationInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -19133,13 +18770,6 @@ func (ec *executionContext) marshalOIdentity2ᚖgoᚗproboᚗincᚋproboᚋpkg return ec._Identity(ctx, sel, v) } -func (ec *executionContext) marshalOIdentityProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐIdentityProfile(ctx context.Context, sel ast.SelectionSet, v *types.IdentityProfile) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._IdentityProfile(ctx, sel, v) -} - func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v any) (*int, error) { if v == nil { return nil, nil @@ -19227,6 +18857,13 @@ func (ec *executionContext) unmarshalOMembershipOrder2ᚖgoᚗproboᚗincᚋprob return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOMembershipProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐMembershipProfile(ctx context.Context, sel ast.SelectionSet, v *types.MembershipProfile) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MembershipProfile(ctx, sel, v) +} + func (ec *executionContext) marshalONode2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐNode(ctx context.Context, sel ast.SelectionSet, v types.Node) graphql.Marshaler { if v == nil { return graphql.Null @@ -19441,13 +19078,6 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return res } -func (ec *executionContext) marshalOUpdateIdentityProfilePayload2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐUpdateIdentityProfilePayload(ctx context.Context, sel ast.SelectionSet, v *types.UpdateIdentityProfilePayload) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._UpdateIdentityProfilePayload(ctx, sel, v) -} - func (ec *executionContext) marshalOUpdateOrganizationPayload2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐUpdateOrganizationPayload(ctx context.Context, sel ast.SelectionSet, v *types.UpdateOrganizationPayload) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/pkg/server/api/connect/v1/types/identity.go b/pkg/server/api/connect/v1/types/identity.go index 6aa1936c5..6f77499ae 100644 --- a/pkg/server/api/connect/v1/types/identity.go +++ b/pkg/server/api/connect/v1/types/identity.go @@ -20,6 +20,7 @@ func NewIdentity(identity *coredata.Identity) *Identity { return &Identity{ ID: identity.ID, Email: identity.EmailAddress, + FullName: identity.FullName, EmailVerified: identity.EmailAddressVerified, CreatedAt: identity.CreatedAt, UpdatedAt: identity.UpdatedAt, diff --git a/pkg/server/api/connect/v1/types/identity_profile.go b/pkg/server/api/connect/v1/types/identity_profile.go index e279cda5f..1097c396e 100644 --- a/pkg/server/api/connect/v1/types/identity_profile.go +++ b/pkg/server/api/connect/v1/types/identity_profile.go @@ -16,8 +16,8 @@ package types import "go.probo.inc/probo/pkg/coredata" -func NewIdentityProfile(profile *coredata.IdentityProfile) *IdentityProfile { - return &IdentityProfile{ +func NewMembershipProfile(profile *coredata.MembershipProfile) *MembershipProfile { + return &MembershipProfile{ ID: profile.ID, FullName: profile.FullName, CreatedAt: profile.CreatedAt, diff --git a/pkg/server/api/connect/v1/types/types.go b/pkg/server/api/connect/v1/types/types.go index d0e758599..0e4e9452f 100644 --- a/pkg/server/api/connect/v1/types/types.go +++ b/pkg/server/api/connect/v1/types/types.go @@ -151,10 +151,10 @@ type ForgotPasswordPayload struct { type Identity struct { ID gid.GID `json:"id"` Email mail.Addr `json:"email"` + FullName string `json:"fullName"` EmailVerified bool `json:"emailVerified"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` - DefaultProfile *IdentityProfile `json:"defaultProfile,omitempty"` Memberships *MembershipConnection `json:"memberships,omitempty"` PendingInvitations *InvitationConnection `json:"pendingInvitations,omitempty"` Sessions *SessionConnection `json:"sessions,omitempty"` @@ -164,17 +164,6 @@ type Identity struct { func (Identity) IsNode() {} func (this Identity) GetID() gid.GID { return this.ID } -type IdentityProfile struct { - ID gid.GID `json:"id"` - FullName string `json:"fullName"` - Identity *Identity `json:"identity"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -func (IdentityProfile) IsNode() {} -func (this IdentityProfile) GetID() gid.GID { return this.ID } - type Invitation struct { ID gid.GID `json:"id"` Email mail.Addr `json:"email"` @@ -208,7 +197,7 @@ type Membership struct { ID gid.GID `json:"id"` CreatedAt time.Time `json:"createdAt"` Identity *Identity `json:"identity,omitempty"` - Profile *IdentityProfile `json:"profile,omitempty"` + Profile *MembershipProfile `json:"profile,omitempty"` Organization *Organization `json:"organization,omitempty"` Role coredata.MembershipRole `json:"role"` Permissions []*Permission `json:"permissions"` @@ -223,6 +212,16 @@ type MembershipEdge struct { Cursor page.CursorKey `json:"cursor"` } +type MembershipProfile struct { + ID gid.GID `json:"id"` + FullName string `json:"fullName"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` +} + +func (MembershipProfile) IsNode() {} +func (this MembershipProfile) GetID() gid.GID { return this.ID } + type Mutation struct { } @@ -452,15 +451,6 @@ type SignUpPayload struct { Identity *Identity `json:"identity,omitempty"` } -type UpdateIdentityProfileInput struct { - MembershipID gid.GID `json:"membershipId"` - FullName *string `json:"fullName,omitempty"` -} - -type UpdateIdentityProfilePayload struct { - Profile *IdentityProfile `json:"profile,omitempty"` -} - type UpdateOrganizationInput struct { OrganizationID gid.GID `json:"organizationId"` Name *string `json:"name,omitempty"` diff --git a/pkg/server/api/connect/v1/v1_resolver.go b/pkg/server/api/connect/v1/v1_resolver.go index 98d5946fe..2b705e0e9 100644 --- a/pkg/server/api/connect/v1/v1_resolver.go +++ b/pkg/server/api/connect/v1/v1_resolver.go @@ -24,17 +24,6 @@ import ( "go.probo.inc/probo/pkg/server/gqlutils/types/cursor" ) -// DefaultProfile is the resolver for the defaultProfile field. -func (r *identityResolver) DefaultProfile(ctx context.Context, obj *types.Identity) (*types.IdentityProfile, error) { - profile, err := r.iam.AccountService.GetDefaultProfile(ctx, obj.ID) - if err != nil { - r.logger.ErrorCtx(ctx, "cannot get default profile", log.Error(err)) - return nil, gqlutils.InternalServerError(ctx) - } - - return types.NewIdentityProfile(profile), nil -} - // Memberships is the resolver for the memberships field. func (r *identityResolver) Memberships(ctx context.Context, obj *types.Identity, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MembershipOrderBy) (*types.MembershipConnection, error) { pageOrderBy := page.OrderBy[coredata.MembershipOrderField]{ @@ -166,7 +155,7 @@ func (r *membershipResolver) Identity(ctx context.Context, obj *types.Membership } // Profile is the resolver for the profile field. -func (r *membershipResolver) Profile(ctx context.Context, obj *types.Membership) (*types.IdentityProfile, error) { +func (r *membershipResolver) Profile(ctx context.Context, obj *types.Membership) (*types.MembershipProfile, error) { profile, err := r.iam.AccountService.GetProfileForMembership(ctx, obj.ID) if err != nil { var errProfileNotFound *iam.ErrProfileNotFound @@ -178,7 +167,7 @@ func (r *membershipResolver) Profile(ctx context.Context, obj *types.Membership) return nil, gqlutils.InternalServerError(ctx) } - return types.NewIdentityProfile(profile), nil + return types.NewMembershipProfile(profile), nil } // Organization is the resolver for the organization field. @@ -551,33 +540,6 @@ func (r *mutationResolver) AssumeOrganizationSession(ctx context.Context, input }, nil } -// UpdateIdentityProfile is the resolver for the updateIdentityProfile field. -func (r *mutationResolver) UpdateIdentityProfile(ctx context.Context, input types.UpdateIdentityProfileInput) (*types.UpdateIdentityProfilePayload, error) { - identity := IdentityFromContext(ctx) - - profile, err := r.iam.AccountService.UpdateIdentityProfile( - ctx, - identity.ID, - &iam.UpdateIdentityProfileRequest{ - MembershipID: input.MembershipID, - FullName: input.FullName, - }, - ) - if err != nil { - var errMembershipNotFound *iam.ErrMembershipNotFound - if errors.As(err, &errMembershipNotFound) { - return nil, gqlutils.NotFound(err) - } - - r.logger.ErrorCtx(ctx, "cannot update identity profile", log.Error(err)) - return nil, gqlutils.InternalServerError(ctx) - } - - return &types.UpdateIdentityProfilePayload{ - Profile: types.NewIdentityProfile(profile), - }, nil -} - // RevokeSession is the resolver for the revokeSession field. func (r *mutationResolver) RevokeSession(ctx context.Context, input types.RevokeSessionInput) (*types.RevokeSessionPayload, error) { identity := IdentityFromContext(ctx) diff --git a/pkg/server/api/console/v1/v1_resolver.go b/pkg/server/api/console/v1/v1_resolver.go index 815237a45..3d09bd41a 100644 --- a/pkg/server/api/console/v1/v1_resolver.go +++ b/pkg/server/api/console/v1/v1_resolver.go @@ -2167,18 +2167,11 @@ func (r *mutationResolver) ExportFramework(ctx context.Context, input types.Expo prb := r.ProboService(ctx, input.FrameworkID.TenantID()) identity := connect_v1.IdentityFromContext(ctx) - // Load default profile to get the full name - recipientName := "" - profile, err := r.iam.AccountService.GetDefaultProfile(ctx, identity.ID) - if err == nil { - recipientName = profile.FullName - } - exportErr, exportJobID := prb.Frameworks.RequestExport( ctx, input.FrameworkID, identity.EmailAddress, - recipientName, + identity.FullName, ) if exportErr != nil { panic(fmt.Errorf("cannot export framework: %w", exportErr)) @@ -3352,20 +3345,13 @@ func (r *mutationResolver) BulkExportDocuments(ctx context.Context, input types. identity := connect_v1.IdentityFromContext(ctx) - // Load default profile to get the full name - recipientName := "" - profile, err := r.iam.AccountService.GetDefaultProfile(ctx, identity.ID) - if err == nil { - recipientName = profile.FullName - } - options := probo.ExportPDFOptions{ WithWatermark: input.WithWatermark, WithSignatures: input.WithSignatures, WatermarkEmail: input.WatermarkEmail, } - documentExport, exportErr := prb.Documents.RequestExport(ctx, input.DocumentIds, identity.EmailAddress, recipientName, options) + documentExport, exportErr := prb.Documents.RequestExport(ctx, input.DocumentIds, identity.EmailAddress, identity.FullName, options) if exportErr != nil { panic(fmt.Errorf("cannot request document export: %w", exportErr)) }