Skip to content

Scheduling infrastructure for absolutely everyone.

fix: auto accept (#15975)

sean-brydon92d0fc6eb425
diff --git a/packages/lib/server/repository/organization.test.ts b/packages/lib/server/repository/organization.test.ts
index d59df04ab3c..3038858e14c 100644
--- a/packages/lib/server/repository/organization.test.ts
+++ b/packages/lib/server/repository/organization.test.ts
@@ -25,8 +25,8 @@ describe("Organization.findUniqueByMatchingAutoAcceptEmail", () => {
});
it("should throw an error if multiple organizations match the email domain", async () => {
- await createOrganization({ name: "Test Org 1", orgAutoAcceptEmail: "example.com" });
- await createOrganization({ name: "Test Org 2", orgAutoAcceptEmail: "example.com" });
+ await createReviewedOrganization({ name: "Test Org 1", orgAutoAcceptEmail: "example.com" });
+ await createReviewedOrganization({ name: "Test Org 2", orgAutoAcceptEmail: "example.com" });
await expect(
OrganizationRepository.findUniqueByMatchingAutoAcceptEmail({ email: "[email protected]" })
@@ -34,7 +34,10 @@ describe("Organization.findUniqueByMatchingAutoAcceptEmail", () => {
});
it("should return the parsed organization if a single match is found", async () => {
- const organization = await createOrganization({ name: "Test Org", orgAutoAcceptEmail: "example.com" });
+ const organization = await createReviewedOrganization({
+ name: "Test Org",
+ orgAutoAcceptEmail: "example.com",
+ });
const result = await OrganizationRepository.findUniqueByMatchingAutoAcceptEmail({
@@ -54,7 +57,7 @@ describe("Organization.findUniqueByMatchingAutoAcceptEmail", () => {
});
it("should correctly match orgAutoAcceptEmail", async () => {
- await createOrganization({ name: "Test Org", orgAutoAcceptEmail: "noexample.com" });
+ await createReviewedOrganization({ name: "Test Org", orgAutoAcceptEmail: "noexample.com" });
const result = await OrganizationRepository.findUniqueByMatchingAutoAcceptEmail({
@@ -64,7 +67,7 @@ describe("Organization.findUniqueByMatchingAutoAcceptEmail", () => {
});
});
-async function createOrganization({
+async function createReviewedOrganization({
name = "Test Org",
orgAutoAcceptEmail,
}: {
@@ -78,6 +81,8 @@ async function createOrganization({
organizationSettings: {
create: {
orgAutoAcceptEmail,
+ isOrganizationVerified: true,
+ isAdminReviewed: true,
},
},
},
diff --git a/packages/lib/server/repository/organization.ts b/packages/lib/server/repository/organization.ts
index 26fa8a97d96..3bb8ade09f2 100644
--- a/packages/lib/server/repository/organization.ts
+++ b/packages/lib/server/repository/organization.ts
@@ -172,10 +172,16 @@ export class OrganizationRepository {
isOrganization: true,
organizationSettings: {
orgAutoAcceptEmail: emailDomain,
+ isOrganizationVerified: true,
+ isAdminReviewed: true,
},
},
});
if (orgs.length > 1) {
+ logger.error(
+ "Multiple organizations found with the same auto accept email domain",
+ safeStringify({ orgs, emailDomain })
+ );
// Detect and fail just in case this situation arises. We should really identify the problem in this case and fix the data.
throw new Error("Multiple organizations found with the same auto accept email domain");
}