mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +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.
|
||||
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);
|
||||
|
||||
if (!hasOrganizationMembership) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
import { MfaMethod } from "@app/hooks/api/auth/types";
|
||||
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||
import { isLoggedIn } from "@app/hooks/api/reactQuery";
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
const client = new jsrp.client();
|
||||
@@ -69,6 +70,8 @@ export const SignupInvitePage = () => {
|
||||
|
||||
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.
|
||||
const signupErrorCheck = async () => {
|
||||
setIsLoading(true);
|
||||
@@ -240,8 +243,10 @@ export const SignupInvitePage = () => {
|
||||
if (response?.token) {
|
||||
SecurityClient.setSignupToken(response.token);
|
||||
setStep(2);
|
||||
} else {
|
||||
} else if (loggedIn) {
|
||||
navigate({ to: "/login/select-organization", search: { force: true } });
|
||||
} else {
|
||||
navigate({ to: "/login" });
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -75,8 +75,6 @@ export const Route = createFileRoute("/_restrict-login-signup")({
|
||||
middlewares: [stripSearchParams({ callback_port: undefined, force: undefined })]
|
||||
},
|
||||
beforeLoad: async ({ context, location, search }) => {
|
||||
if (location.pathname === "/signupinvite") return;
|
||||
|
||||
if (!context.serverConfig.initialized) {
|
||||
if (location.pathname.endsWith("/admin/signup")) return;
|
||||
throw redirect({ to: "/admin/signup" });
|
||||
@@ -94,6 +92,8 @@ export const Route = createFileRoute("/_restrict-login-signup")({
|
||||
|
||||
setAuthToken(data.token);
|
||||
|
||||
if (location.pathname === "/signupinvite") return;
|
||||
|
||||
// Avoid redirect if on select-organization page with force=true
|
||||
if (location.pathname.endsWith("select-organization") && search?.force === true) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user