Skip to content

Commit

Permalink
wip6
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Jan 22, 2025
1 parent 056fc7a commit 45acf40
Show file tree
Hide file tree
Showing 8 changed files with 754 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export default gql`
"""
Specific services within the target for which the permissions should be applied.
"""
services: MemberServiceAssignmentInput
services: [MemberServiceAssignmentInput!]
}
input MemberTargetAssignmentInput {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createHash } from 'node:crypto';
import { Inject, Injectable, Scope } from 'graphql-modules';
import * as GraphQLSchema from '../../../__generated__/types';
import { Organization } from '../../../shared/entities';
import { HiveError } from '../../../shared/errors';
import { cache, share } from '../../../shared/helpers';
Expand Down Expand Up @@ -1043,7 +1044,12 @@ export class OrganizationManager {
};
}

async assignMemberRole(input: { organizationSlug: string; userId: string; roleId: string }) {
async assignMemberRole(input: {
organizationSlug: string;
userId: string;
roleId: string;
resources: GraphQLSchema.MemberResourceAssignmentInput;
}) {
const organizationId = await this.idTranslator.translateOrganizationId(input);

await this.session.assertPerformAction({
Expand Down Expand Up @@ -1078,11 +1084,18 @@ export class OrganizationManager {
};
}

const resourceAssignmentGroup =
await this.organizationMembers.transformGraphQLMemberResourceAssignmentInputToResourceAssignmentGroup(
organization,
input.resources,
);

// Assign the role to the member
await this.storage.assignOrganizationMemberRole({
await this.organizationMembers.assignOrganizationMemberRole({
organizationId,
userId: input.userId,
roleId: input.roleId,
resourceAssignmentGroup,
});

// Access cache is stale by now
Expand Down
Loading

0 comments on commit 45acf40

Please sign in to comment.