Skip to content

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

fix query invalidation

Thiago Araujo da Silva29d59f99334b
diff --git a/backend/src/services/user/user-service.ts b/backend/src/services/user/user-service.ts
index 7472033661..a68eea9565 100644
--- a/backend/src/services/user/user-service.ts
+++ b/backend/src/services/user/user-service.ts
@@ -14,7 +14,7 @@ import { TokenType } from "@app/services/auth-token/auth-token-types";
import { TOrgDALFactory } from "@app/services/org/org-dal";
import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service";
-import { ActorType, AuthMethod, AuthModeSignUpTokenPayload, AuthTokenType } from "../auth/auth-type";
+import { ActorType, AuthMethod, AuthModeSignUpTokenPayload, AuthTokenType, MfaMethod } from "../auth/auth-type";
import { TGroupProjectDALFactory } from "../group-project/group-project-dal";
import { TMembershipUserDALFactory } from "../membership-user/membership-user-dal";
import { TMfaRecoveryCodeServiceFactory } from "../mfa-recovery-code/mfa-recovery-code-service";
@@ -142,7 +142,7 @@ export const userServiceFactory = ({
{
isMfaEnabled,
mfaMethods,
- selectedMfaMethod
+ selectedMfaMethod: isMfaEnabled === false ? MfaMethod.EMAIL : selectedMfaMethod
},
tx
);
diff --git a/frontend/src/hooks/api/users/mutation.tsx b/frontend/src/hooks/api/users/mutation.tsx
index 8b8636e9b4..c99d0491d4 100644
--- a/frontend/src/hooks/api/users/mutation.tsx
+++ b/frontend/src/hooks/api/users/mutation.tsx
@@ -93,6 +93,7 @@ export const useDeleteUserTotpConfiguration = () => {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: userKeys.totpConfiguration });
queryClient.removeQueries({ queryKey: userKeys.totpRegistration });
+ queryClient.invalidateQueries({ queryKey: userKeys.getUser });
}
});
};
diff --git a/frontend/src/hooks/api/webauthn/mutations.tsx b/frontend/src/hooks/api/webauthn/mutations.tsx
index f8294041ea..bed98a9bd8 100644
--- a/frontend/src/hooks/api/webauthn/mutations.tsx
+++ b/frontend/src/hooks/api/webauthn/mutations.tsx
@@ -1,6 +1,7 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
+import { userKeys } from "@app/hooks/api/users/query-keys";
import { webAuthnKeys } from "./queries";
import {
@@ -74,6 +75,7 @@ export const useDeleteWebAuthnCredential = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: webAuthnKeys.credentials });
+ queryClient.invalidateQueries({ queryKey: userKeys.getUser });
}
});
};
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
index 1b45a93cf8..5727c4980e 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
@@ -27,6 +27,7 @@ import { MfaMethod } from "@app/hooks/api/auth/types";
import { useGetUserTotpConfiguration } from "@app/hooks/api/users";
import { AuthMethod } from "@app/hooks/api/users/types";
import { useGetWebAuthnCredentials } from "@app/hooks/api/webauthn";
+import { webAuthnKeys } from "@app/hooks/api/webauthn/queries";
import { MfaMethodsCard } from "./MfaMethodsCard";
import { MfaSetupWizard } from "./MfaSetupWizard";
@@ -91,7 +92,8 @@ export const MFASection = () => {
await Promise.all([
queryClient.invalidateQueries({ queryKey: userKeys.getUser }),
queryClient.invalidateQueries({ queryKey: userKeys.totpConfiguration }),
- queryClient.invalidateQueries({ queryKey: userKeys.mfaRecoveryCodes })
+ queryClient.invalidateQueries({ queryKey: userKeys.mfaRecoveryCodes }),
+ queryClient.invalidateQueries({ queryKey: webAuthnKeys.credentials })
]);
setIsDisableOpen(false);
createNotification({ text: "Two-factor authentication disabled", type: "success" });