Rename identity profile on membership profile
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -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!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user