mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-04 17:56:38 +00:00
scope niceid to the orgId
This commit is contained in:
@@ -242,7 +242,12 @@ async function updateHttpResource(
|
|||||||
const [existingResource] = await db
|
const [existingResource] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(resources)
|
.from(resources)
|
||||||
.where(eq(resources.niceId, updateData.niceId));
|
.where(
|
||||||
|
and(
|
||||||
|
eq(resources.niceId, updateData.niceId),
|
||||||
|
eq(resources.orgId, resource.orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
existingResource &&
|
existingResource &&
|
||||||
@@ -387,7 +392,12 @@ async function updateRawResource(
|
|||||||
const [existingResource] = await db
|
const [existingResource] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(resources)
|
.from(resources)
|
||||||
.where(eq(resources.niceId, updateData.niceId));
|
.where(
|
||||||
|
and(
|
||||||
|
eq(resources.niceId, updateData.niceId),
|
||||||
|
eq(resources.orgId, resource.orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
existingResource &&
|
existingResource &&
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Request, Response, NextFunction } from "express";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { sites } from "@server/db";
|
import { sites } from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
@@ -95,7 +95,12 @@ export async function updateSite(
|
|||||||
const existingSite = await db
|
const existingSite = await db
|
||||||
.select()
|
.select()
|
||||||
.from(sites)
|
.from(sites)
|
||||||
.where(eq(sites.niceId, updateData.niceId))
|
.where(
|
||||||
|
and(
|
||||||
|
eq(sites.niceId, updateData.niceId),
|
||||||
|
eq(sites.orgId, sites.orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (existingSite.length > 0 && existingSite[0].siteId !== siteId) {
|
if (existingSite.length > 0 && existingSite[0].siteId !== siteId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user