Skip to content

Commit 088001c

Browse files
fix(web): use auth context prisma instead of global import in audit and userManagement actions
Replace direct @/prisma imports with the prisma instance from the withAuth callback to ensure userScopedPrismaClientExtension is applied. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 22d9269 commit 088001c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/web/src/ee/features/audit/actions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { sew } from "@/middleware/sew";
44
import { getAuditService } from "@/ee/features/audit/factory";
55
import { ErrorCode } from "@/lib/errorCodes";
66
import { ServiceError } from "@/lib/serviceError";
7-
import { prisma } from "@/prisma";
87
import { withAuth } from "@/middleware/withAuth";
98
import { withMinimumOrgRole } from "@/middleware/withMinimumOrgRole";
109
import { createLogger } from "@sourcebot/shared";
@@ -34,7 +33,7 @@ export interface FetchAuditRecordsParams {
3433
}
3534

3635
export const fetchAuditRecords = async (params: FetchAuditRecordsParams) => sew(() =>
37-
withAuth(async ({ user, org, role }) =>
36+
withAuth(async ({ user, org, role, prisma }) =>
3837
withMinimumOrgRole(role, OrgRole.OWNER, async () => {
3938
try {
4039
const where = {

packages/web/src/ee/features/userManagement/actions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { sew } from "@/middleware/sew";
44
import { getAuditService } from "@/ee/features/audit/factory";
55
import { ErrorCode } from "@/lib/errorCodes";
66
import { notFound, ServiceError } from "@/lib/serviceError";
7-
import { prisma } from "@/prisma";
87
import { withAuth } from "@/middleware/withAuth";
98
import { withMinimumOrgRole } from "@/middleware/withMinimumOrgRole";
109
import { OrgRole, Prisma } from "@sourcebot/db";
@@ -20,7 +19,7 @@ const orgManagementNotAvailable = (): ServiceError => ({
2019
});
2120

2221
export const promoteToOwner = async (memberId: string): Promise<{ success: boolean } | ServiceError> => sew(() =>
23-
withAuth(async ({ user, org, role }) =>
22+
withAuth(async ({ user, org, role, prisma }) =>
2423
withMinimumOrgRole(role, OrgRole.OWNER, async () => {
2524
if (!hasEntitlement('org-management')) {
2625
return orgManagementNotAvailable();
@@ -82,7 +81,7 @@ export const promoteToOwner = async (memberId: string): Promise<{ success: boole
8281
);
8382

8483
export const demoteToMember = async (memberId: string): Promise<{ success: boolean } | ServiceError> => sew(() =>
85-
withAuth(async ({ user, org, role }) =>
84+
withAuth(async ({ user, org, role, prisma }) =>
8685
withMinimumOrgRole(role, OrgRole.OWNER, async () => {
8786
if (!hasEntitlement('org-management')) {
8887
return orgManagementNotAvailable();

0 commit comments

Comments
 (0)