Fix select org

This commit is contained in:
x032205
2025-06-05 11:30:05 -04:00
parent 4f67834eaa
commit 5255f0ac17
4 changed files with 6 additions and 26 deletions

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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