mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
fix: multiple MFA mails bug
This commit is contained in:
@@ -880,6 +880,7 @@ export const Navbar = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
setShowSubOrgForm(false);
|
setShowSubOrgForm(false);
|
||||||
}}
|
}}
|
||||||
|
handleOrgSelection={handleOrgSelection}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|||||||
+5
-23
@@ -1,20 +1,18 @@
|
|||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { useNavigate, useRouter } from "@tanstack/react-router";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||||
import { Button, FormControl, Input } from "@app/components/v2";
|
import { Button, FormControl, Input } from "@app/components/v2";
|
||||||
import { useOrganization } from "@app/context";
|
import { useOrganization } from "@app/context";
|
||||||
import { projectKeys, subOrganizationsQuery, useCreateSubOrganization } from "@app/hooks/api";
|
import { useCreateSubOrganization } from "@app/hooks/api";
|
||||||
import { authKeys, selectOrganization } from "@app/hooks/api/auth/queries";
|
import { selectOrganization } from "@app/hooks/api/auth/queries";
|
||||||
import { slugSchema } from "@app/lib/schemas";
|
import { slugSchema } from "@app/lib/schemas";
|
||||||
import { navigateUserToOrg } from "@app/pages/auth/LoginPage/Login.utils";
|
|
||||||
|
|
||||||
type ContentProps = {
|
type ContentProps = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
handleOrgSelection: (params: { organizationId: string }) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AddOrgSchema = z.object({
|
const AddOrgSchema = z.object({
|
||||||
@@ -23,11 +21,9 @@ const AddOrgSchema = z.object({
|
|||||||
|
|
||||||
type FormData = z.infer<typeof AddOrgSchema>;
|
type FormData = z.infer<typeof AddOrgSchema>;
|
||||||
|
|
||||||
export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
|
export const NewSubOrganizationForm = ({ onClose, handleOrgSelection }: ContentProps) => {
|
||||||
const { currentOrg, isSubOrganization } = useOrganization();
|
const { currentOrg, isSubOrganization } = useOrganization();
|
||||||
const createSubOrg = useCreateSubOrganization();
|
const createSubOrg = useCreateSubOrganization();
|
||||||
const subOrgQuery = subOrganizationsQuery.list({ limit: 500, isAccessible: true });
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@@ -40,9 +36,6 @@ export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
|
|||||||
resolver: zodResolver(AddOrgSchema)
|
resolver: zodResolver(AddOrgSchema)
|
||||||
});
|
});
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const onSubmit = async ({ name }: FormData) => {
|
const onSubmit = async ({ name }: FormData) => {
|
||||||
if (isSubOrganization && currentOrg.rootOrgId) {
|
if (isSubOrganization && currentOrg.rootOrgId) {
|
||||||
const { token } = await selectOrganization({
|
const { token } = await selectOrganization({
|
||||||
@@ -63,18 +56,7 @@ export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
|
|||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
|
|
||||||
const { token } = await selectOrganization({
|
await handleOrgSelection({ organizationId: organization.id });
|
||||||
organizationId: organization.id
|
|
||||||
});
|
|
||||||
|
|
||||||
SecurityClient.setToken(token);
|
|
||||||
SecurityClient.setProviderAuthToken("");
|
|
||||||
queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
|
|
||||||
queryClient.removeQueries({ queryKey: subOrgQuery.queryKey });
|
|
||||||
|
|
||||||
await router.invalidate({ sync: true }).catch(() => null);
|
|
||||||
await navigateUserToOrg({ navigate, organizationId: organization.id });
|
|
||||||
queryClient.removeQueries({ queryKey: projectKeys.allProjectQueries() });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user