@@ -30,7 +30,7 @@ import (
|
||||
type (
|
||||
Invitation struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `fb:"organization_id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
UserID gid.GID `db:"user_id"`
|
||||
Status InvitationStatus `db:"status"`
|
||||
ExpiresAt time.Time `db:"expires_at"`
|
||||
|
||||
@@ -78,11 +78,15 @@ FROM
|
||||
WHERE
|
||||
accepted_at IS NULL
|
||||
ORDER BY
|
||||
email
|
||||
email,
|
||||
created_at DESC
|
||||
) i ON CONFLICT (email_address) DO
|
||||
UPDATE
|
||||
SET
|
||||
full_name = EXCLUDED.full_name;
|
||||
full_name = COALESCE(
|
||||
NULLIF(identities.full_name, ''),
|
||||
EXCLUDED.full_name
|
||||
);
|
||||
|
||||
-- Create missing profiles
|
||||
WITH invitation_identities AS (
|
||||
@@ -193,7 +197,8 @@ WITH orphan_invitations AS (
|
||||
LEFT JOIN identities i ON i.email_address = inv.email
|
||||
LEFT JOIN iam_membership_profiles p ON p.identity_id = i.id
|
||||
WHERE
|
||||
i.id IS NULL OR p.id IS NULL
|
||||
i.id IS NULL
|
||||
OR p.id IS NULL
|
||||
)
|
||||
DELETE FROM
|
||||
iam_invitations
|
||||
@@ -218,4 +223,4 @@ ALTER COLUMN
|
||||
ALTER COLUMN
|
||||
role DROP NOT NULL,
|
||||
ALTER COLUMN
|
||||
full_name DROP NOT NULL;
|
||||
full_name DROP NOT NULL;
|
||||
|
||||
@@ -308,7 +308,7 @@ func (s *Service) HandleAssertion(
|
||||
}
|
||||
|
||||
profile = &coredata.MembershipProfile{
|
||||
ID: gid.New(membership.ID.TenantID(), coredata.MembershipProfileEntityType),
|
||||
ID: gid.New(configID.TenantID(), coredata.MembershipProfileEntityType),
|
||||
IdentityID: identity.ID,
|
||||
OrganizationID: config.OrganizationID,
|
||||
Source: coredata.ProfileSourceSAML,
|
||||
@@ -324,7 +324,7 @@ func (s *Service) HandleAssertion(
|
||||
}
|
||||
} else {
|
||||
if profile.State == coredata.ProfileStateInactive {
|
||||
return NewUserInactiveError(membership.ID)
|
||||
return NewUserInactiveError(profile.ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -489,7 +489,6 @@ type InvitationConnection
|
||||
) {
|
||||
edges: [InvitationEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
totalCount: Int @goField(forceResolver: true)
|
||||
}
|
||||
|
||||
type InvitationEdge {
|
||||
|
||||
@@ -50,7 +50,6 @@ type ResolverRoot interface {
|
||||
Connector() ConnectorResolver
|
||||
Identity() IdentityResolver
|
||||
Invitation() InvitationResolver
|
||||
InvitationConnection() InvitationConnectionResolver
|
||||
Membership() MembershipResolver
|
||||
Mutation() MutationResolver
|
||||
Organization() OrganizationResolver
|
||||
@@ -172,9 +171,8 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
InvitationConnection struct {
|
||||
Edges func(childComplexity int) int
|
||||
PageInfo func(childComplexity int) int
|
||||
TotalCount func(childComplexity int) int
|
||||
Edges func(childComplexity int) int
|
||||
PageInfo func(childComplexity int) int
|
||||
}
|
||||
|
||||
InvitationEdge struct {
|
||||
@@ -507,9 +505,6 @@ type InvitationResolver interface {
|
||||
Organization(ctx context.Context, obj *types.Invitation) (*types.Organization, error)
|
||||
Permission(ctx context.Context, obj *types.Invitation, action string) (bool, error)
|
||||
}
|
||||
type InvitationConnectionResolver interface {
|
||||
TotalCount(ctx context.Context, obj *types.InvitationConnection) (*int, error)
|
||||
}
|
||||
type MembershipResolver interface {
|
||||
LastSession(ctx context.Context, obj *types.Membership) (*types.Session, error)
|
||||
Permission(ctx context.Context, obj *types.Membership, action string) (bool, error)
|
||||
@@ -953,12 +948,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
}
|
||||
|
||||
return e.complexity.InvitationConnection.PageInfo(childComplexity), true
|
||||
case "InvitationConnection.totalCount":
|
||||
if e.complexity.InvitationConnection.TotalCount == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.InvitationConnection.TotalCount(childComplexity), true
|
||||
|
||||
case "InvitationEdge.cursor":
|
||||
if e.complexity.InvitationEdge.Cursor == nil {
|
||||
@@ -2965,7 +2954,6 @@ type InvitationConnection
|
||||
) {
|
||||
edges: [InvitationEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
totalCount: Int @goField(forceResolver: true)
|
||||
}
|
||||
|
||||
type InvitationEdge {
|
||||
@@ -6013,35 +6001,6 @@ func (ec *executionContext) fieldContext_InvitationConnection_pageInfo(_ context
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _InvitationConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *types.InvitationConnection) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
ec.OperationContext,
|
||||
field,
|
||||
ec.fieldContext_InvitationConnection_totalCount,
|
||||
func(ctx context.Context) (any, error) {
|
||||
return ec.resolvers.InvitationConnection().TotalCount(ctx, obj)
|
||||
},
|
||||
nil,
|
||||
ec.marshalOInt2ᚖint,
|
||||
true,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_InvitationConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "InvitationConnection",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Int does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _InvitationEdge_node(ctx context.Context, field graphql.CollectedField, obj *types.InvitationEdge) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
@@ -9967,8 +9926,6 @@ func (ec *executionContext) fieldContext_Profile_pendingInvitations(ctx context.
|
||||
return ec.fieldContext_InvitationConnection_edges(ctx, field)
|
||||
case "pageInfo":
|
||||
return ec.fieldContext_InvitationConnection_pageInfo(ctx, field)
|
||||
case "totalCount":
|
||||
return ec.fieldContext_InvitationConnection_totalCount(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type InvitationConnection", field.Name)
|
||||
},
|
||||
@@ -17787,46 +17744,13 @@ func (ec *executionContext) _InvitationConnection(ctx context.Context, sel ast.S
|
||||
case "edges":
|
||||
out.Values[i] = ec._InvitationConnection_edges(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
out.Invalids++
|
||||
}
|
||||
case "pageInfo":
|
||||
out.Values[i] = ec._InvitationConnection_pageInfo(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
out.Invalids++
|
||||
}
|
||||
case "totalCount":
|
||||
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._InvitationConnection_totalCount(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) })
|
||||
default:
|
||||
panic("unknown field " + strconv.Quote(field.Name))
|
||||
}
|
||||
|
||||
@@ -24,9 +24,8 @@ type (
|
||||
InvitationOrderBy OrderBy[coredata.InvitationOrderField]
|
||||
|
||||
InvitationConnection struct {
|
||||
TotalCount int
|
||||
Edges []*InvitationEdge
|
||||
PageInfo PageInfo
|
||||
Edges []*InvitationEdge
|
||||
PageInfo PageInfo
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
|
||||
@@ -220,11 +220,6 @@ func (r *invitationResolver) Permission(ctx context.Context, obj *types.Invitati
|
||||
return r.Resolver.Permission(ctx, obj, action)
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *invitationConnectionResolver) TotalCount(ctx context.Context, obj *types.InvitationConnection) (*int, error) {
|
||||
panic(fmt.Errorf("not implemented: TotalCount - totalCount"))
|
||||
}
|
||||
|
||||
// LastSession is the resolver for the lastSession field.
|
||||
func (r *membershipResolver) LastSession(ctx context.Context, obj *types.Membership) (*types.Session, error) {
|
||||
if err := r.authorize(ctx, obj.ID, iam.ActionMembershipGet, authz.WithSkipAssumptionCheck()); err != nil {
|
||||
@@ -837,7 +832,7 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input types.CreateUse
|
||||
if err != nil {
|
||||
var errAlreadyExists *iam.ErrUserAlreadyExists
|
||||
if errors.As(err, &errAlreadyExists) {
|
||||
return nil, gqlutils.Conflictf(ctx, "user %q already exists", input.EmailAddress.String())
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create user", log.Error(err))
|
||||
@@ -1418,13 +1413,6 @@ func (r *profileResolver) PendingInvitations(ctx context.Context, obj *types.Pro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if gqlutils.OnlyTotalCountSelected(ctx) {
|
||||
return &types.InvitationConnection{
|
||||
Resolver: r,
|
||||
ParentID: obj.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.InvitationOrderField]{
|
||||
Field: coredata.InvitationOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
@@ -1450,14 +1438,14 @@ func (r *profileResolver) Permission(ctx context.Context, obj *types.Profile, ac
|
||||
func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.ProfileConnection) (*int, error) {
|
||||
switch obj.Resolver.(type) {
|
||||
case *identityResolver:
|
||||
count, err := r.iam.AccountService.CountProfiles(ctx, obj.ParentID, coredata.NewMembershipProfileFilter(nil))
|
||||
count, err := r.iam.AccountService.CountProfiles(ctx, obj.ParentID, obj.Filters)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count profiles", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
return &count, nil
|
||||
case *organizationResolver:
|
||||
count, err := r.iam.OrganizationService.CountProfiles(ctx, obj.ParentID, coredata.NewMembershipProfileFilter(nil))
|
||||
count, err := r.iam.OrganizationService.CountProfiles(ctx, obj.ParentID, obj.Filters)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count profiles", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -1900,11 +1888,6 @@ func (r *Resolver) Identity() schema.IdentityResolver { return &identityResolver
|
||||
// Invitation returns schema.InvitationResolver implementation.
|
||||
func (r *Resolver) Invitation() schema.InvitationResolver { return &invitationResolver{r} }
|
||||
|
||||
// InvitationConnection returns schema.InvitationConnectionResolver implementation.
|
||||
func (r *Resolver) InvitationConnection() schema.InvitationConnectionResolver {
|
||||
return &invitationConnectionResolver{r}
|
||||
}
|
||||
|
||||
// Membership returns schema.MembershipResolver implementation.
|
||||
func (r *Resolver) Membership() schema.MembershipResolver { return &membershipResolver{r} }
|
||||
|
||||
@@ -1970,7 +1953,6 @@ func (r *Resolver) SessionConnection() schema.SessionConnectionResolver {
|
||||
type connectorResolver struct{ *Resolver }
|
||||
type identityResolver struct{ *Resolver }
|
||||
type invitationResolver struct{ *Resolver }
|
||||
type invitationConnectionResolver struct{ *Resolver }
|
||||
type membershipResolver struct{ *Resolver }
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type organizationResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user