From 15a12fa5e8f0a5bda77343bc21bb4fbb7dba2fc8 Mon Sep 17 00:00:00 2001 From: Gautam Manchandani Date: Thu, 18 Dec 2025 18:11:56 +0530 Subject: [PATCH] added test case --- .../organization/routes/crud-org.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/better-auth/src/plugins/organization/routes/crud-org.test.ts b/packages/better-auth/src/plugins/organization/routes/crud-org.test.ts index 79e0c6e9e3..0b8efb94f8 100644 --- a/packages/better-auth/src/plugins/organization/routes/crud-org.test.ts +++ b/packages/better-auth/src/plugins/organization/routes/crud-org.test.ts @@ -444,4 +444,32 @@ describe("organization hooks", async () => { }); expect(afterCreateTeam).toHaveBeenCalled(); }); + + it("should allow internal organization creation when disabled for users", async () => { + const { auth } = await getTestInstance({ + plugins: [ + organization({ + allowUserToCreateOrganization: false, + }), + ], + }); + + const newUser = await auth.api.signUpEmail({ + body: { + email: "internal@test.com", + password: "password", + name: "Internal User", + }, + }); + + const internalOrg = await auth.api.createOrganization({ + body: { + name: "Internal Org", + slug: "internal-org", + userId: newUser.user.id, + }, + }); + expect(internalOrg).toBeDefined(); + expect(internalOrg?.name).toBe("Internal Org"); + }); });