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