mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 17:27:16 +00:00
Fix accepting invite while logged out
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);
|
const hasOrganizationMembership = userOrgs.some((org) => org.id === organizationId && org.userStatus !== "invited");
|
||||||
const selectedOrg = await orgDAL.findById(organizationId);
|
const selectedOrg = await orgDAL.findById(organizationId);
|
||||||
|
|
||||||
if (!hasOrganizationMembership) {
|
if (!hasOrganizationMembership) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
import { MfaMethod } from "@app/hooks/api/auth/types";
|
import { MfaMethod } from "@app/hooks/api/auth/types";
|
||||||
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
||||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||||
|
import { isLoggedIn } from "@app/hooks/api/reactQuery";
|
||||||
|
|
||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
const client = new jsrp.client();
|
const client = new jsrp.client();
|
||||||
@@ -69,6 +70,8 @@ export const SignupInvitePage = () => {
|
|||||||
|
|
||||||
const { mutateAsync: selectOrganization } = useSelectOrganization();
|
const { mutateAsync: selectOrganization } = useSelectOrganization();
|
||||||
|
|
||||||
|
const loggedIn = isLoggedIn();
|
||||||
|
|
||||||
// Verifies if the information that the users entered (name, workspace) is there, and if the password matched the criteria.
|
// Verifies if the information that the users entered (name, workspace) is there, and if the password matched the criteria.
|
||||||
const signupErrorCheck = async () => {
|
const signupErrorCheck = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -240,8 +243,10 @@ export const SignupInvitePage = () => {
|
|||||||
if (response?.token) {
|
if (response?.token) {
|
||||||
SecurityClient.setSignupToken(response.token);
|
SecurityClient.setSignupToken(response.token);
|
||||||
setStep(2);
|
setStep(2);
|
||||||
} else {
|
} else if (loggedIn) {
|
||||||
navigate({ to: "/login/select-organization", search: { force: true } });
|
navigate({ to: "/login/select-organization", search: { force: true } });
|
||||||
|
} else {
|
||||||
|
navigate({ to: "/login" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ export const Route = createFileRoute("/_restrict-login-signup")({
|
|||||||
middlewares: [stripSearchParams({ callback_port: undefined, force: undefined })]
|
middlewares: [stripSearchParams({ callback_port: undefined, force: undefined })]
|
||||||
},
|
},
|
||||||
beforeLoad: async ({ context, location, search }) => {
|
beforeLoad: async ({ context, location, search }) => {
|
||||||
if (location.pathname === "/signupinvite") return;
|
|
||||||
|
|
||||||
if (!context.serverConfig.initialized) {
|
if (!context.serverConfig.initialized) {
|
||||||
if (location.pathname.endsWith("/admin/signup")) return;
|
if (location.pathname.endsWith("/admin/signup")) return;
|
||||||
throw redirect({ to: "/admin/signup" });
|
throw redirect({ to: "/admin/signup" });
|
||||||
@@ -94,6 +92,8 @@ export const Route = createFileRoute("/_restrict-login-signup")({
|
|||||||
|
|
||||||
setAuthToken(data.token);
|
setAuthToken(data.token);
|
||||||
|
|
||||||
|
if (location.pathname === "/signupinvite") return;
|
||||||
|
|
||||||
// Avoid redirect if on select-organization page with force=true
|
// 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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user