Skip to content

Commit

Permalink
fix(organizations): enabled access for org affiliates to org update e…
Browse files Browse the repository at this point in the history
…ndpoint
  • Loading branch information
AndySakov committed Nov 8, 2024
1 parent 5fe22fa commit e86d9c3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/organizations/organizations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,10 @@ export class OrganizationsController {

@Post("/update/:id")
@UseGuards(PBACGuard)
@Permissions(CheckWalletPermissions.ADMIN, CheckWalletPermissions.ORG_MANAGER)
@Permissions(
[CheckWalletPermissions.USER, CheckWalletPermissions.ORG_AFFILIATE],
[CheckWalletPermissions.ADMIN, CheckWalletPermissions.ORG_MANAGER],
)
@ApiOkResponse({
description: "Updates an existing organization",
schema: responseSchemaWrapper({
Expand All @@ -553,7 +556,7 @@ export class OrganizationsController {
schema: responseSchemaWrapper({ type: "string" }),
})
async updateOrganization(
@Session() { address }: SessionObject,
@Session() { address, permissions }: SessionObject,
@Param("id") id: string,
@Body() body: UpdateOrganizationInput,
): Promise<ResponseWithOptionalData<Organization>> {
Expand All @@ -563,6 +566,19 @@ export class OrganizationsController {
)} from ${address}`,
);

if (permissions.includes(CheckWalletPermissions.ORG_AFFILIATE)) {
const authorized = await this.userService.userAuthorizedForOrg(
address,
id,
);
if (!authorized) {
throw new ForbiddenException({
success: false,
message: "You are not authorized to access this resource",
});
}
}

try {
const org = await this.organizationsService.findByOrgId(id);

Expand Down

0 comments on commit e86d9c3

Please sign in to comment.