mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 20:27:12 +00:00
Fix select org
This commit is contained in:
@@ -397,7 +397,7 @@ export const authLoginServiceFactory = ({
|
|||||||
|
|
||||||
// Check if the user actually has access to the specified organization.
|
// Check if the user actually has access to the specified organization.
|
||||||
const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
|
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);
|
const selectedOrg = await orgDAL.findById(organizationId);
|
||||||
|
|
||||||
if (!hasOrganizationMembership) {
|
if (!hasOrganizationMembership) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Helmet } from "react-helmet";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
|
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
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 axios from "axios";
|
||||||
import { addSeconds, formatISO } from "date-fns";
|
import { addSeconds, formatISO } from "date-fns";
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
@@ -51,6 +51,7 @@ export const SelectOrganizationSection = () => {
|
|||||||
|
|
||||||
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
|
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
const queryParams = new URLSearchParams(window.location.search);
|
const queryParams = new URLSearchParams(window.location.search);
|
||||||
const orgId = queryParams.get("org_id");
|
const orgId = queryParams.get("org_id");
|
||||||
const callbackPort = queryParams.get("callback_port");
|
const callbackPort = queryParams.get("callback_port");
|
||||||
@@ -118,6 +119,8 @@ export const SelectOrganizationSection = () => {
|
|||||||
})
|
})
|
||||||
.finally(() => setIsInitialOrgCheckLoading(false));
|
.finally(() => setIsInitialOrgCheckLoading(false));
|
||||||
|
|
||||||
|
await router.invalidate();
|
||||||
|
|
||||||
if (isMfaEnabled) {
|
if (isMfaEnabled) {
|
||||||
SecurityClient.setMfaToken(token);
|
SecurityClient.setMfaToken(token);
|
||||||
if (mfaMethod) {
|
if (mfaMethod) {
|
||||||
|
|||||||
@@ -244,30 +244,6 @@ export const SignupInvitePage = () => {
|
|||||||
setStep(2);
|
setStep(2);
|
||||||
} else {
|
} else {
|
||||||
navigate({ to: "/login/select-organization", search: { force: true } });
|
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) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export const Route = createFileRoute("/_restrict-login-signup")({
|
|||||||
|
|
||||||
setAuthToken(data.token);
|
setAuthToken(data.token);
|
||||||
|
|
||||||
|
// Avoid redirect if on select-organization page with force=true
|
||||||
if (location.pathname.endsWith("select-organization") && search?.force === true) return;
|
if (location.pathname.endsWith("select-organization") && search?.force === true) return;
|
||||||
|
|
||||||
// to do cli login
|
// to do cli login
|
||||||
|
|||||||
Reference in New Issue
Block a user