fix(web): machine org permission visibility

This commit is contained in:
BennyKok 2024-01-01 23:50:42 +08:00
parent c66de45522
commit 8190740abf

View File

@ -11,13 +11,18 @@ import "server-only";
import type { z } from "zod"; import type { z } from "zod";
export async function getMachines() { export async function getMachines() {
const { userId } = auth(); const { userId, orgId } = auth();
if (!userId) throw new Error("No user id"); if (!userId) throw new Error("No user id");
const machines = await db const machines = await db
.select() .select()
.from(machinesTable) .from(machinesTable)
.where( .where(
and(eq(machinesTable.user_id, userId), eq(machinesTable.disabled, false)) and(
orgId
? eq(machinesTable.org_id, orgId)
: eq(machinesTable.user_id, userId),
eq(machinesTable.disabled, false)
)
); );
return machines; return machines;
} }