forked from bai/curriculum-project-hub
fix: enforce active organization boundary
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { PermissionRole, Prisma, PrismaClient } from "@prisma/client";
|
||||
import { lockActiveOrganization } from "../org/status.js";
|
||||
|
||||
export interface GrantTeamProjectAccessInput {
|
||||
readonly projectId: string;
|
||||
@@ -30,6 +31,7 @@ export async function grantTeamProjectAccess(
|
||||
): Promise<ProjectTeamAccessEntry> {
|
||||
return prisma.$transaction(async (tx) => {
|
||||
const { project, team } = await resolveProjectAndTeam(tx, input);
|
||||
await lockActiveOrganization(tx, project.organizationId);
|
||||
const now = new Date();
|
||||
const existing = await tx.permissionGrant.findFirst({
|
||||
where: {
|
||||
@@ -87,6 +89,7 @@ export async function revokeTeamProjectAccess(
|
||||
): Promise<number> {
|
||||
return prisma.$transaction(async (tx) => {
|
||||
const { project, team } = await resolveProjectAndTeam(tx, input);
|
||||
await lockActiveOrganization(tx, project.organizationId);
|
||||
const result = await tx.permissionGrant.updateMany({
|
||||
where: {
|
||||
resourceType: "PROJECT",
|
||||
|
||||
Reference in New Issue
Block a user