Fix: Request access permissions

This commit is contained in:
Daniel Hougaard
2024-05-07 17:30:35 +02:00
parent 073a9ee6a4
commit 15c747e8e8
2 changed files with 10 additions and 3 deletions
@@ -248,7 +248,14 @@ export const accessApprovalPolicyServiceFactory = ({
if (!project) throw new BadRequestError({ message: "Project not found" }); 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 }); const environment = await projectEnvDAL.findOne({ projectId: project.id, slug: envSlug });
if (!environment) throw new BadRequestError({ message: "Environment not found" }); if (!environment) throw new BadRequestError({ message: "Environment not found" });
@@ -272,14 +272,14 @@ export const accessApprovalRequestServiceFactory = ({
const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId); const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
if (!project) throw new UnauthorizedError({ message: "Project not found" }); if (!project) throw new UnauthorizedError({ message: "Project not found" });
const { permission } = await permissionService.getProjectPermission( const { membership } = await permissionService.getProjectPermission(
actor, actor,
actorId, actorId,
project.id, project.id,
actorAuthMethod, actorAuthMethod,
actorOrgId 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 }); const count = await accessApprovalRequestDAL.getCount({ projectId: project.id });