Skip to content

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

fix: invalidation for logging in

varonix0bc79f57348d1
diff --git a/frontend/src/hooks/api/auth/queries.tsx b/frontend/src/hooks/api/auth/queries.tsx
index bef629bfe6..efbb9636d0 100644
--- a/frontend/src/hooks/api/auth/queries.tsx
+++ b/frontend/src/hooks/api/auth/queries.tsx
@@ -81,6 +81,11 @@ export const useSelectOrganization = () => {
// If a custom user agent is set, then this session is meant for another consuming application, not the web application.
if (!details.userAgent && !data.isMfaEnabled) {
SecurityClient.setToken(data.token);
+
+ queryClient.removeQueries({ queryKey: adminQueryKeys.serverConfig() });
+ queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
+ await queryClient.refetchQueries({ queryKey: authKeys.getAuthToken });
+ await queryClient.refetchQueries({ queryKey: adminQueryKeys.serverConfig() });
}
if (data.token && !data.isMfaEnabled) {
@@ -101,10 +106,8 @@ export const useSelectOrganization = () => {
return data;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: authKeys.getAuthToken });
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
- queryClient.invalidateQueries({ queryKey: adminQueryKeys.serverConfig() });
}
});
};
diff --git a/frontend/src/pages/auth/SelectOrgPage/route.tsx b/frontend/src/pages/auth/SelectOrgPage/route.tsx
index ab4efa5105..1664fc3ee0 100644
--- a/frontend/src/pages/auth/SelectOrgPage/route.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/route.tsx
@@ -5,6 +5,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { SessionStorageKeys } from "@app/const";
+import { adminQueryKeys } from "@app/hooks/api/admin/queries";
import { authKeys, selectOrganization } from "@app/hooks/api/auth/queries";
import { UserAgentType } from "@app/hooks/api/auth/types";
import {
@@ -99,6 +100,12 @@ export const Route = createFileRoute("/_restrict-login-signup/login/select-organ
}
setAuthToken(result.token);
+
+ context.queryClient.removeQueries({ queryKey: adminQueryKeys.serverConfig() });
+ context.queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
+ await context.queryClient.refetchQueries({ queryKey: authKeys.getAuthToken });
+ await context.queryClient.refetchQueries({ queryKey: adminQueryKeys.serverConfig() });
+
createNotification({ text: "Successfully logged in", type: "success" });
throw redirect({