Skip to content

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

Fix select org

x0322055255f0ac17a3
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index 64ba573d51..bee85b14c7 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -397,7 +397,7 @@ export const authLoginServiceFactory = ({
// Check if the user actually has access to the specified organization.
const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
- const hasOrganizationMembership = userOrgs.some((org) => org.id === organizationId && org.userStatus !== "invited");
+ const hasOrganizationMembership = userOrgs.some((org) => org.id === organizationId);
const selectedOrg = await orgDAL.findById(organizationId);
if (!hasOrganizationMembership) {
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx
index a736b52a76..ac194cd05d 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx
@@ -3,7 +3,7 @@ import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { Link, useNavigate } from "@tanstack/react-router";
+import { Link, useNavigate, useRouter } from "@tanstack/react-router";
import axios from "axios";
import { addSeconds, formatISO } from "date-fns";
import { jwtDecode } from "jwt-decode";
@@ -51,6 +51,7 @@ export const SelectOrganizationSection = () => {
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
+ const router = useRouter();
const queryParams = new URLSearchParams(window.location.search);
const orgId = queryParams.get("org_id");
const callbackPort = queryParams.get("callback_port");
@@ -118,6 +119,8 @@ export const SelectOrganizationSection = () => {
})
.finally(() => setIsInitialOrgCheckLoading(false));
+ await router.invalidate();
+
if (isMfaEnabled) {
SecurityClient.setMfaToken(token);
if (mfaMethod) {
diff --git a/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx b/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx
index 2db4f7901e..23a9c49303 100644
--- a/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx
+++ b/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx
@@ -244,30 +244,6 @@ export const SignupInvitePage = () => {
setStep(2);
} else {
navigate({ to: "/login/select-organization", search: { force: true } });
-
- // TODO: Redirect user to the newly joined org. The commented code does not work due to auth issues.
- // const redirectExistingUser = async () => {
- // try {
- // const { token: mfaToken, isMfaEnabled } = await selectOrganization({
- // organizationId
- // });
-
- // if (isMfaEnabled) {
- // SecurityClient.setMfaToken(mfaToken);
- // toggleShowMfa.on();
- // setMfaSuccessCallback(() => redirectExistingUser);
- // return;
- // }
-
- // // user will be redirected to dashboard
- // // if not logged in gets kicked out to login
- // await navigateUserToOrg(navigate, organizationId);
- // } catch (err) {
- // navigate({ to: "/login" });
- // }
- // };
-
- // await redirectExistingUser();
}
}
} catch (err) {
diff --git a/frontend/src/pages/middlewares/restrict-login-signup.tsx b/frontend/src/pages/middlewares/restrict-login-signup.tsx
index 210f848ccc..f22ba82fe9 100644
--- a/frontend/src/pages/middlewares/restrict-login-signup.tsx
+++ b/frontend/src/pages/middlewares/restrict-login-signup.tsx
@@ -94,6 +94,7 @@ export const Route = createFileRoute("/_restrict-login-signup")({
setAuthToken(data.token);
+ // Avoid redirect if on select-organization page with force=true
if (location.pathname.endsWith("select-organization") && search?.force === true) return;
// to do cli login