mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 21:27:31 +00:00
fix: MFA enabled orgs redirect
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute, isRedirect, redirect } from "@tanstack/react-router";
|
||||||
|
|
||||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||||
import { authKeys, fetchAuthToken, selectOrganization } from "@app/hooks/api/auth/queries";
|
import { authKeys, fetchAuthToken, selectOrganization } from "@app/hooks/api/auth/queries";
|
||||||
@@ -27,6 +27,13 @@ export const Route = createFileRoute("/_authenticate/_inject-org-details")({
|
|||||||
try {
|
try {
|
||||||
const { token, isMfaEnabled } = await selectOrganization({ organizationId: urlOrgId });
|
const { token, isMfaEnabled } = await selectOrganization({ organizationId: urlOrgId });
|
||||||
|
|
||||||
|
if (isMfaEnabled) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/login/select-organization",
|
||||||
|
search: { org_id: urlOrgId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!isMfaEnabled && token) {
|
if (!isMfaEnabled && token) {
|
||||||
SecurityClient.setToken(token);
|
SecurityClient.setToken(token);
|
||||||
SecurityClient.setProviderAuthToken("");
|
SecurityClient.setProviderAuthToken("");
|
||||||
@@ -41,6 +48,9 @@ export const Route = createFileRoute("/_authenticate/_inject-org-details")({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (isRedirect(error)) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
console.warn("Failed to automatically exchange token for organization:", error);
|
console.warn("Failed to automatically exchange token for organization:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user