Skip to content

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

fix: add logout on close

Sheen Capadngan31a67b6dfed4
diff --git a/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx b/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
index 0049b61ad1..e36a42df93 100644
--- a/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
+++ b/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
@@ -31,9 +31,10 @@ export type FormData = z.infer<typeof schema>;
interface CreateOrgModalProps {
isOpen: boolean;
onClose?: () => void;
+ logoutOnClose?: boolean;
}
-export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) => {
+export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose, logoutOnClose }) => {
const navigate = useNavigate();
const {
@@ -75,16 +76,20 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
onClose?.();
};
+ const handleOpenChange = async (open: boolean) => {
+ if (!open) {
+ reset();
+ if (logoutOnClose) {
+ await logout.mutateAsync();
+ navigate({ to: "/login" });
+ } else {
+ onClose?.();
+ }
+ }
+ };
+
return (
- <Dialog
- open={isOpen}
- onOpenChange={(open) => {
- if (!open) {
- reset();
- onClose?.();
- }
- }}
- >
+ <Dialog open={isOpen} onOpenChange={handleOpenChange}>
<DialogContent className="max-w-md">
<DialogHeader>
<DialogTitle>Create Organization</DialogTitle>
@@ -121,20 +126,6 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
Create
</Button>
</DialogFooter>
- {!onClose && (
- <div className="mt-4 text-center">
- <button
- type="button"
- className="text-sm text-mineshaft-400 underline-offset-4 hover:text-mineshaft-200 hover:underline"
- onClick={async () => {
- await logout.mutateAsync();
- navigate({ to: "/login" });
- }}
- >
- Log out
- </button>
- </div>
- )}
</form>
</DialogContent>
</Dialog>
diff --git a/frontend/src/pages/organization/NoOrgPage/NoOrgPage.tsx b/frontend/src/pages/organization/NoOrgPage/NoOrgPage.tsx
index 9568a0f153..eff5c6354e 100644
--- a/frontend/src/pages/organization/NoOrgPage/NoOrgPage.tsx
+++ b/frontend/src/pages/organization/NoOrgPage/NoOrgPage.tsx
@@ -13,7 +13,7 @@ export const NoOrgPage = () => {
<link rel="icon" href="/infisical.ico" />
</Helmet>
<div className="min-h-screen bg-bunker-800">
- <CreateOrgModal isOpen />
+ <CreateOrgModal isOpen logoutOnClose />
</div>
</>
);