Skip to content

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

Move useOrganization outside ShareSecretForm as it's used on a public page

carlosmonastyrskiea27870ce334
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx b/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx
index 3378313b71..45b974755e 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx
@@ -1,4 +1,5 @@
import { Modal, ModalContent } from "@app/components/v2";
+import { useOrganization } from "@app/context";
import { UsePopUpState } from "@app/hooks/usePopUp";
import { ShareSecretForm } from "@app/pages/public/ShareSecretPage/components";
@@ -11,6 +12,7 @@ type Props = {
};
export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
return (
<Modal
isOpen={popUp?.createSharedSecret?.isOpen}
@@ -25,6 +27,9 @@ export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => {
<ShareSecretForm
isPublic={false}
value={(popUp.createSharedSecret.data as { value?: string })?.value}
+ allowSecretSharingOutsideOrganization={
+ currentOrg?.allowSecretSharingOutsideOrganization ?? true
+ }
/>
</ModalContent>
</Modal>
diff --git a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx
index 07a6336fa5..a2228e46b7 100644
--- a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx
+++ b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx
@@ -7,7 +7,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2";
-import { useOrganization } from "@app/context";
import { useTimedReset } from "@app/hooks";
import { useCreatePublicSharedSecret, useCreateSharedSecret } from "@app/hooks/api";
import { SecretSharingAccessType } from "@app/hooks/api/secretSharing";
@@ -42,11 +41,15 @@ export type FormData = z.infer<typeof schema>;
type Props = {
isPublic: boolean; // whether or not this is a public (non-authenticated) secret sharing form
value?: string;
+ allowSecretSharingOutsideOrganization?: boolean;
};
-export const ShareSecretForm = ({ isPublic, value }: Props) => {
+export const ShareSecretForm = ({
+ isPublic,
+ value,
+ allowSecretSharingOutsideOrganization = true
+}: Props) => {
const [secretLink, setSecretLink] = useState("");
- const { currentOrg } = useOrganization();
const [, isCopyingSecret, setCopyTextSecret] = useTimedReset<string>({
initialState: "Copy to clipboard"
});
@@ -232,7 +235,7 @@ export const ShareSecretForm = ({ isPublic, value }: Props) => {
onValueChange={(e) => onChange(e)}
className="w-full"
>
- {currentOrg?.allowSecretSharingOutsideOrganization && (
+ {allowSecretSharingOutsideOrganization && (
<SelectItem value={SecretSharingAccessType.Anyone}>Anyone</SelectItem>
)}
<SelectItem value={SecretSharingAccessType.Organization}>