Fix: Request access permissions

This commit is contained in:
Daniel Hougaard
2024-04-03 17:48:27 -07:00
parent 073a9ee6a4
commit 15c747e8e8
2 changed files with 10 additions and 3 deletions

View File

@@ -248,7 +248,14 @@ export const accessApprovalPolicyServiceFactory = ({
if (!project) throw new BadRequestError({ message: "Project not found" });
await permissionService.getProjectPermission(actor, actorId, project.id, actorAuthMethod, actorOrgId);
const { membership } = await permissionService.getProjectPermission(
actor,
actorId,
project.id,
actorAuthMethod,
actorOrgId
);
if (!membership) throw new BadRequestError({ message: "User not found in project" });
const environment = await projectEnvDAL.findOne({ projectId: project.id, slug: envSlug });
if (!environment) throw new BadRequestError({ message: "Environment not found" });

View File

@@ -272,14 +272,14 @@ export const accessApprovalRequestServiceFactory = ({
const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
if (!project) throw new UnauthorizedError({ message: "Project not found" });
const { permission } = await permissionService.getProjectPermission(
const { membership } = await permissionService.getProjectPermission(
actor,
actorId,
project.id,
actorAuthMethod,
actorOrgId
);
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval);
if (!membership) throw new BadRequestError({ message: "User not found in project" });
const count = await accessApprovalRequestDAL.getCount({ projectId: project.id });