Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(ui): restrict sub-organization creation to root context (#8413)

Andrew Huang3bde3a1aca71
diff --git a/frontend/src/components/organization/NewSubOrganizationModal/NewSubOrganizationModal.tsx b/frontend/src/components/organization/NewSubOrganizationModal/NewSubOrganizationModal.tsx
index 4d0c8c6696..aef618f7d7 100644
--- a/frontend/src/components/organization/NewSubOrganizationModal/NewSubOrganizationModal.tsx
+++ b/frontend/src/components/organization/NewSubOrganizationModal/NewSubOrganizationModal.tsx
@@ -4,7 +4,6 @@ import slugify from "@sindresorhus/slugify";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import SecurityClient from "@app/components/utilities/SecurityClient";
import {
Button,
Dialog,
@@ -23,7 +22,6 @@ import {
} from "@app/components/v3";
import { useOrganization } from "@app/context";
import { TSubOrganization, useCreateSubOrganization } from "@app/hooks/api";
-import { selectOrganization } from "@app/hooks/api/auth/queries";
import { GenericResourceNameSchema, slugSchema } from "@app/lib/schemas";
type Props = {
@@ -41,7 +39,7 @@ const AddOrgSchema = z.object({
type FormData = z.infer<typeof AddOrgSchema>;
export const NewSubOrganizationModal = ({ isOpen, onOpenChange, onCreated }: Props) => {
- const { currentOrg, isSubOrganization } = useOrganization();
+ const { isSubOrganization } = useOrganization();
const createSubOrg = useCreateSubOrganization();
const {
@@ -64,13 +62,7 @@ export const NewSubOrganizationModal = ({ isOpen, onOpenChange, onCreated }: Pro
};
const onSubmit = async ({ name, slug }: FormData) => {
- if (isSubOrganization && currentOrg.rootOrgId) {
- const { token } = await selectOrganization({
- organizationId: currentOrg.rootOrgId
- });
-
- SecurityClient.setToken(token);
- }
+ if (isSubOrganization) return;
const { organization } = await createSubOrg.mutateAsync({
name,
@@ -87,7 +79,7 @@ export const NewSubOrganizationModal = ({ isOpen, onOpenChange, onCreated }: Pro
};
return (
- <Dialog open={isOpen} onOpenChange={handleOpenChange}>
+ <Dialog open={isOpen && !isSubOrganization} onOpenChange={handleOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle>Create Sub-Organization</DialogTitle>
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
index 2e14b7246c..9bc5827e8d 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
@@ -559,7 +559,7 @@ export const Navbar = () => {
a={OrgPermissionSubjects.SubOrganization}
>
{(isAllowed) =>
- isAllowed ? (
+ isAllowed && !isSubOrganization ? (
<CommandItem
className="text-muted"
onSelect={() => {