mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-04 02:09:43 +02:00
Always pull all of the users for the blueprints
This commit is contained in:
@@ -51,7 +51,7 @@ import { tierMatrix } from "../billing/tierMatrix";
|
||||
import { isValidCIDR, isValidIP, isValidUrlGlobPattern } from "../validators";
|
||||
import { Config, isTargetsOnlyResource, TargetData } from "./types";
|
||||
import { getOrCreateLabelIds, syncResourceLabels } from "./labels";
|
||||
import { findOrgUserByIdentifier } from "./findOrgUser";
|
||||
import { findOrgUsersByIdentifier } from "./findOrgUser";
|
||||
import { LimitId } from "../billing";
|
||||
import { usageService } from "../billing/usageService";
|
||||
import { syncInferenceAiConfig } from "./aiProviders";
|
||||
@@ -1564,21 +1564,27 @@ async function syncUserResources(
|
||||
.where(eq(userResources.resourceId, resourceId));
|
||||
|
||||
for (const username of ssoUsers) {
|
||||
const user = await findOrgUserByIdentifier(trx, orgId, username);
|
||||
const matchedUsers = await findOrgUsersByIdentifier(
|
||||
trx,
|
||||
orgId,
|
||||
username
|
||||
);
|
||||
|
||||
if (!user) {
|
||||
if (matchedUsers.length === 0) {
|
||||
throw new Error(`User not found: ${username} in org ${orgId}`);
|
||||
}
|
||||
|
||||
const existingUserResource = existingUserResources.find(
|
||||
(rr) => rr.userId === user.userId
|
||||
);
|
||||
for (const user of matchedUsers) {
|
||||
const existingUserResource = existingUserResources.find(
|
||||
(rr) => rr.userId === user.userId
|
||||
);
|
||||
|
||||
if (!existingUserResource) {
|
||||
await trx.insert(userResources).values({
|
||||
userId: user.userId,
|
||||
resourceId: resourceId
|
||||
});
|
||||
if (!existingUserResource) {
|
||||
await trx.insert(userResources).values({
|
||||
userId: user.userId,
|
||||
resourceId: resourceId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1946,21 +1952,27 @@ async function syncUserPolicies(
|
||||
.where(eq(userPolicies.resourcePolicyId, policyId));
|
||||
|
||||
for (const username of ssoUsers) {
|
||||
const user = await findOrgUserByIdentifier(trx, orgId, username);
|
||||
const matchedUsers = await findOrgUsersByIdentifier(
|
||||
trx,
|
||||
orgId,
|
||||
username
|
||||
);
|
||||
|
||||
if (!user) {
|
||||
if (matchedUsers.length === 0) {
|
||||
throw new Error(`User not found: ${username} in org ${orgId}`);
|
||||
}
|
||||
|
||||
const existingUserPolicy = existingUserPoliciesList.find(
|
||||
(up) => up.userId === user.userId
|
||||
);
|
||||
for (const user of matchedUsers) {
|
||||
const existingUserPolicy = existingUserPoliciesList.find(
|
||||
(up) => up.userId === user.userId
|
||||
);
|
||||
|
||||
if (!existingUserPolicy) {
|
||||
await trx.insert(userPolicies).values({
|
||||
userId: user.userId,
|
||||
resourcePolicyId: policyId
|
||||
});
|
||||
if (!existingUserPolicy) {
|
||||
await trx.insert(userPolicies).values({
|
||||
userId: user.userId,
|
||||
resourcePolicyId: policyId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user