Fix 5xx on profile request
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -69,9 +69,6 @@ func NewMembership(membership *coredata.Membership) *Membership {
|
|||||||
Organization: &Organization{
|
Organization: &Organization{
|
||||||
ID: membership.OrganizationID,
|
ID: membership.OrganizationID,
|
||||||
},
|
},
|
||||||
Profile: &MembershipProfile{
|
|
||||||
ID: membership.ID,
|
|
||||||
},
|
|
||||||
Role: membership.Role,
|
Role: membership.Role,
|
||||||
Source: membership.Source,
|
Source: membership.Source,
|
||||||
State: membership.State,
|
State: membership.State,
|
||||||
|
|||||||
@@ -246,15 +246,7 @@ func (r *membershipResolver) Identity(ctx context.Context, obj *types.Membership
|
|||||||
|
|
||||||
// Profile is the resolver for the profile field.
|
// Profile is the resolver for the profile field.
|
||||||
func (r *membershipResolver) Profile(ctx context.Context, obj *types.Membership) (*types.MembershipProfile, error) {
|
func (r *membershipResolver) Profile(ctx context.Context, obj *types.Membership) (*types.MembershipProfile, error) {
|
||||||
if err := r.authorize(ctx, obj.Profile.ID, iam.ActionMembershipProfileGet); err != nil {
|
// TODO: PorfileID must leave on membership to allow perform the ACL lookup first and load after.
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if gqlutils.OnlyIDSelected(ctx) {
|
|
||||||
return &types.MembershipProfile{
|
|
||||||
ID: obj.Profile.ID,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
profile, err := r.iam.AccountService.GetProfileForMembership(ctx, obj.ID)
|
profile, err := r.iam.AccountService.GetProfileForMembership(ctx, obj.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -267,6 +259,10 @@ func (r *membershipResolver) Profile(ctx context.Context, obj *types.Membership)
|
|||||||
return nil, gqlutils.Internal(ctx)
|
return nil, gqlutils.Internal(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := r.authorize(ctx, profile.ID, iam.ActionMembershipProfileGet); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return types.NewMembershipProfile(profile), nil
|
return types.NewMembershipProfile(profile), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user