Reimplement remove / create in console
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -18,6 +18,11 @@ WHERE
|
||||
ALTER TABLE
|
||||
iam_membership_profiles DROP COLUMN membership_id;
|
||||
|
||||
ALTER TABLE
|
||||
iam_memberships
|
||||
ALTER COLUMN
|
||||
source DROP NOT NULL;
|
||||
|
||||
ALTER TABLE
|
||||
iam_scim_events
|
||||
ADD
|
||||
@@ -29,7 +34,7 @@ WITH emails AS (
|
||||
m.id
|
||||
FROM
|
||||
iam_memberships m
|
||||
INNER JOIN identities i ON i.id = m.identity_id
|
||||
INNER JOIN identities i ON i.id = m.identity_id
|
||||
)
|
||||
UPDATE
|
||||
iam_scim_events se
|
||||
|
||||
@@ -164,7 +164,9 @@ var IAMOwnerPolicy = policy.NewPolicy(
|
||||
policy.Allow(
|
||||
ActionMembershipProfileGet,
|
||||
ActionMembershipProfileList,
|
||||
ActionMembershipProfileCreate,
|
||||
ActionMembershipProfileUpdate,
|
||||
ActionMembershipProfileDelete,
|
||||
).
|
||||
WithSID("full-membership-profile-access").
|
||||
When(policy.Equals("principal.organization_id", "resource.organization_id")),
|
||||
@@ -243,7 +245,9 @@ var IAMAdminPolicy = policy.NewPolicy(
|
||||
policy.Allow(
|
||||
ActionMembershipProfileGet,
|
||||
ActionMembershipProfileList,
|
||||
ActionMembershipProfileCreate,
|
||||
ActionMembershipProfileUpdate,
|
||||
ActionMembershipProfileDelete,
|
||||
).
|
||||
WithSID("membership-profile-admin-access").
|
||||
When(policy.Equals("principal.organization_id", "resource.organization_id")),
|
||||
|
||||
@@ -942,7 +942,7 @@ func (s *OrganizationService) CreateUser(ctx context.Context, req *CreateUserReq
|
||||
now = time.Now()
|
||||
)
|
||||
|
||||
err := s.pg.WithConn(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
identity := &coredata.Identity{}
|
||||
@@ -966,6 +966,9 @@ func (s *OrganizationService) CreateUser(ctx context.Context, req *CreateUserReq
|
||||
|
||||
profile = &coredata.MembershipProfile{
|
||||
ID: gid.New(req.OrganizationID.TenantID(), coredata.MembershipProfileEntityType),
|
||||
IdentityID: identity.ID,
|
||||
OrganizationID: req.OrganizationID,
|
||||
Source: coredata.ProfileSourceManual,
|
||||
FullName: req.FullName,
|
||||
Kind: req.Kind,
|
||||
AdditionalEmailAddresses: req.AdditionalEmailAddresses,
|
||||
|
||||
@@ -183,6 +183,7 @@ type Identity implements Node {
|
||||
type Profile implements Node {
|
||||
id: ID!
|
||||
fullName: String!
|
||||
emailAddress: EmailAddr!
|
||||
source: String!
|
||||
state: ProfileState!
|
||||
additionalEmailAddresses: [EmailAddr!]!
|
||||
|
||||
@@ -294,6 +294,7 @@ type ComplexityRoot struct {
|
||||
ContractEndDate func(childComplexity int) int
|
||||
ContractStartDate func(childComplexity int) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
EmailAddress func(childComplexity int) int
|
||||
FullName func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Identity func(childComplexity int) int
|
||||
@@ -1663,6 +1664,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
}
|
||||
|
||||
return e.complexity.Profile.CreatedAt(childComplexity), true
|
||||
case "Profile.emailAddress":
|
||||
if e.complexity.Profile.EmailAddress == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Profile.EmailAddress(childComplexity), true
|
||||
case "Profile.fullName":
|
||||
if e.complexity.Profile.FullName == nil {
|
||||
break
|
||||
@@ -2708,6 +2715,7 @@ type Identity implements Node {
|
||||
type Profile implements Node {
|
||||
id: ID!
|
||||
fullName: String!
|
||||
emailAddress: EmailAddr!
|
||||
source: String!
|
||||
state: ProfileState!
|
||||
additionalEmailAddresses: [EmailAddr!]!
|
||||
@@ -9003,6 +9011,8 @@ func (ec *executionContext) fieldContext_Organization_viewer(_ context.Context,
|
||||
return ec.fieldContext_Profile_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_Profile_fullName(ctx, field)
|
||||
case "emailAddress":
|
||||
return ec.fieldContext_Profile_emailAddress(ctx, field)
|
||||
case "source":
|
||||
return ec.fieldContext_Profile_source(ctx, field)
|
||||
case "state":
|
||||
@@ -9796,6 +9806,35 @@ func (ec *executionContext) fieldContext_Profile_fullName(_ context.Context, fie
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Profile_emailAddress(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
ec.OperationContext,
|
||||
field,
|
||||
ec.fieldContext_Profile_emailAddress,
|
||||
func(ctx context.Context) (any, error) {
|
||||
return obj.EmailAddress, nil
|
||||
},
|
||||
nil,
|
||||
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
|
||||
true,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Profile_emailAddress(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Profile",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type EmailAddr does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Profile_source(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
@@ -10433,6 +10472,8 @@ func (ec *executionContext) fieldContext_ProfileEdge_node(_ context.Context, fie
|
||||
return ec.fieldContext_Profile_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_Profile_fullName(ctx, field)
|
||||
case "emailAddress":
|
||||
return ec.fieldContext_Profile_emailAddress(ctx, field)
|
||||
case "source":
|
||||
return ec.fieldContext_Profile_source(ctx, field)
|
||||
case "state":
|
||||
@@ -13907,6 +13948,8 @@ func (ec *executionContext) fieldContext_UpdateUserPayload_profile(_ context.Con
|
||||
return ec.fieldContext_Profile_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_Profile_fullName(ctx, field)
|
||||
case "emailAddress":
|
||||
return ec.fieldContext_Profile_emailAddress(ctx, field)
|
||||
case "source":
|
||||
return ec.fieldContext_Profile_source(ctx, field)
|
||||
case "state":
|
||||
@@ -19237,6 +19280,11 @@ func (ec *executionContext) _Profile(ctx context.Context, sel ast.SelectionSet,
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "emailAddress":
|
||||
out.Values[i] = ec._Profile_emailAddress(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "source":
|
||||
out.Values[i] = ec._Profile_source(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
|
||||
@@ -310,6 +310,7 @@ type PersonalAPIKeyEdge struct {
|
||||
type Profile struct {
|
||||
ID gid.GID `json:"id"`
|
||||
FullName string `json:"fullName"`
|
||||
EmailAddress mail.Addr `json:"emailAddress"`
|
||||
Source string `json:"source"`
|
||||
State coredata.ProfileState `json:"state"`
|
||||
AdditionalEmailAddresses []mail.Addr `json:"additionalEmailAddresses"`
|
||||
|
||||
@@ -899,6 +899,7 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input types.CreateUse
|
||||
return nil, gqlutils.Conflictf(ctx, "user %q already exists", input.EmailAddress.String())
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create user", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user