mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat: fixed cleanup on leaving root and api issue in frontend
This commit is contained in:
@@ -57,6 +57,7 @@ type TScimServiceFactoryDep = {
|
||||
TOrgDALFactory,
|
||||
| "createMembership"
|
||||
| "findById"
|
||||
| "find"
|
||||
| "findMembership"
|
||||
| "findMembershipWithScimFilter"
|
||||
| "deleteMembershipById"
|
||||
|
||||
@@ -40,7 +40,7 @@ import { newProjectMembershipUserFactory } from "./project/project-membership-us
|
||||
type TMembershipUserServiceFactoryDep = {
|
||||
membershipUserDAL: TMembershipUserDALFactory;
|
||||
membershipRoleDAL: Pick<TMembershipRoleDALFactory, "insertMany" | "delete">;
|
||||
orgDAL: Pick<TOrgDALFactory, "findById" | "transaction">;
|
||||
orgDAL: Pick<TOrgDALFactory, "findById" | "transaction" | "find">;
|
||||
roleDAL: Pick<TRoleDALFactory, "find">;
|
||||
userDAL: TUserDALFactory;
|
||||
permissionService: Pick<
|
||||
@@ -405,7 +405,7 @@ export const membershipUserServiceFactory = ({
|
||||
const membershipDoc = await membershipUserDAL.transaction(async (tx) => {
|
||||
if (dto.scopeData.scope === AccessScope.Organization) {
|
||||
const [doc] = await deleteOrgMembershipsFn({
|
||||
orgMembershipIds: [],
|
||||
orgMembershipIds: [existingMembership.id],
|
||||
orgId: dto.permission.orgId,
|
||||
orgDAL,
|
||||
projectKeyDAL,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { TMembershipUserDALFactory } from "../membership-user/membership-user-da
|
||||
type TDeleteOrgMemberships = {
|
||||
orgMembershipIds: string[];
|
||||
orgId: string;
|
||||
orgDAL: Pick<TOrgDALFactory, "transaction">;
|
||||
orgDAL: Pick<TOrgDALFactory, "transaction" | "find">;
|
||||
userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "delete">;
|
||||
membershipUserDAL: Pick<TMembershipUserDALFactory, "delete" | "find">;
|
||||
membershipRoleDAL: Pick<TMembershipRoleDALFactory, "delete">;
|
||||
@@ -34,19 +34,9 @@ export const deleteOrgMembershipsFn = async ({
|
||||
userId,
|
||||
membershipUserDAL,
|
||||
userGroupMembershipDAL,
|
||||
membershipRoleDAL,
|
||||
additionalPrivilegeDAL
|
||||
}: TDeleteOrgMemberships) => {
|
||||
const deletedMemberships = await orgDAL.transaction(async (tx) => {
|
||||
await membershipRoleDAL.delete(
|
||||
{
|
||||
$in: {
|
||||
membershipId: orgMembershipIds
|
||||
}
|
||||
},
|
||||
tx
|
||||
);
|
||||
|
||||
const orgMemberships = await membershipUserDAL.delete(
|
||||
{
|
||||
scopeOrgId: orgId,
|
||||
@@ -83,12 +73,13 @@ export const deleteOrgMembershipsFn = async ({
|
||||
);
|
||||
|
||||
// Get all the project memberships of the users in the organization
|
||||
const childOrgs = await orgDAL.find({ rootOrgId: orgId }, { tx });
|
||||
|
||||
// Delete all the project memberships of the users in the organization
|
||||
const otherMemberships = await membershipUserDAL.delete(
|
||||
{
|
||||
scopeOrgId: orgId,
|
||||
$in: {
|
||||
scopeOrgId: [orgId].concat(childOrgs.map((el) => el.id)),
|
||||
actorUserId: membershipUserIds
|
||||
}
|
||||
},
|
||||
@@ -96,7 +87,9 @@ export const deleteOrgMembershipsFn = async ({
|
||||
);
|
||||
|
||||
const orgGroups = await membershipUserDAL.find({
|
||||
scopeOrgId: orgId,
|
||||
$in: {
|
||||
scopeOrgId: [orgId].concat(childOrgs.map((el) => el.id))
|
||||
},
|
||||
$notNull: ["actorGroupId"]
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export const useOrganization = () => {
|
||||
});
|
||||
|
||||
const { data: currentOrg } = useSuspenseQuery({
|
||||
queryKey: organizationKeys.getOrgById(organizationId, subOrganization),
|
||||
queryKey: organizationKeys.getOrgById(organizationId, subOrganization || "root"),
|
||||
queryFn: () => fetchOrganizationById(organizationId),
|
||||
staleTime: Infinity
|
||||
});
|
||||
@@ -31,7 +31,7 @@ export const useOrganization = () => {
|
||||
isSubOrganization: Boolean(currentOrg.subOrganization),
|
||||
isRootOrganization: !currentOrg.subOrganization
|
||||
}),
|
||||
[currentOrg]
|
||||
[currentOrg, subOrganization]
|
||||
);
|
||||
|
||||
return org;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
||||
import { createRootRouteWithContext, Outlet, useSearch } from "@tanstack/react-router";
|
||||
|
||||
import { NotificationContainer } from "@app/components/notifications";
|
||||
import { TooltipProvider } from "@app/components/v2";
|
||||
import { adminQueryKeys, fetchServerConfig } from "@app/hooks/api/admin/queries";
|
||||
import { TServerConfig } from "@app/hooks/api/admin/types";
|
||||
import { queryClient } from "@app/hooks/api/reactQuery";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type TRouterContext = {
|
||||
serverConfig: TServerConfig | null;
|
||||
@@ -13,6 +14,15 @@ type TRouterContext = {
|
||||
};
|
||||
|
||||
const RootPage = () => {
|
||||
const subOrganization = useSearch({
|
||||
strict: false,
|
||||
select: (el) => el?.subOrganization
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
queryClient.clear();
|
||||
}, [subOrganization]);
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<TooltipProvider>
|
||||
|
||||
Reference in New Issue
Block a user