mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 11:27:32 +00:00
fix: fix isAcessible query join/filter and clear sub org query cache when org changes
This commit is contained in:
@@ -172,14 +172,16 @@ export const orgDALFactory = (db: TDbClient) => {
|
|||||||
.select(selectAllTableCols(TableName.Organization));
|
.select(selectAllTableCols(TableName.Organization));
|
||||||
|
|
||||||
if (dto.isAccessible) {
|
if (dto.isAccessible) {
|
||||||
void query.leftJoin(`${TableName.Membership}`, (qb) => {
|
void query
|
||||||
void qb.on(`${TableName.Membership}.scope`, AccessScope.Organization);
|
.leftJoin(`${TableName.Membership}`, `${TableName.Membership}.scopeOrgId`, `${TableName.Organization}.id`)
|
||||||
if (dto.actorType === ActorType.IDENTITY) {
|
.where((qb) => {
|
||||||
void qb.andOn(`${TableName.Membership}.actorIdentityId`, dto.actorId);
|
void qb.where(`${TableName.Membership}.scope`, AccessScope.Organization);
|
||||||
} else {
|
if (dto.actorType === ActorType.IDENTITY) {
|
||||||
void qb.andOn(`${TableName.Membership}.actorUserId`, dto.actorId);
|
void qb.andWhere(`${TableName.Membership}.actorIdentityId`, dto.actorId);
|
||||||
}
|
} else {
|
||||||
});
|
void qb.andWhere(`${TableName.Membership}.actorUserId`, dto.actorId);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (dto.limit) void query.limit(dto.limit);
|
if (dto.limit) void query.limit(dto.limit);
|
||||||
if (dto.offset) void query.offset(dto.offset);
|
if (dto.offset) void query.offset(dto.offset);
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ export const Navbar = () => {
|
|||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
const { currentOrg, isSubOrganization } = useOrganization();
|
const { currentOrg, isSubOrganization } = useOrganization();
|
||||||
|
|
||||||
console.log("current", currentOrg, isSubOrganization);
|
|
||||||
|
|
||||||
const [showAdminsModal, setShowAdminsModal] = useState(false);
|
const [showAdminsModal, setShowAdminsModal] = useState(false);
|
||||||
const [showSubOrgForm, setShowSubOrgForm] = useState(false);
|
const [showSubOrgForm, setShowSubOrgForm] = useState(false);
|
||||||
const [showCardDeclinedModal, setShowCardDeclinedModal] = useState(false);
|
const [showCardDeclinedModal, setShowCardDeclinedModal] = useState(false);
|
||||||
|
|
||||||
|
const subOrgQuery = subOrganizationsQuery.list({ limit: 500, isAccessible: true });
|
||||||
const { data: subOrganizations = [] } = useQuery({
|
const { data: subOrganizations = [] } = useQuery({
|
||||||
...subOrganizationsQuery.list({ limit: 500, isAccessible: true }),
|
...subOrgQuery,
|
||||||
enabled: Boolean(subscription.subOrganization)
|
enabled: Boolean(subscription.subOrganization)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -183,6 +183,7 @@ export const Navbar = () => {
|
|||||||
}
|
}
|
||||||
await router.invalidate();
|
await router.invalidate();
|
||||||
await navigateUserToOrg(navigate, orgId);
|
await navigateUserToOrg(navigate, orgId);
|
||||||
|
queryClient.removeQueries({ queryKey: subOrgQuery.queryKey });
|
||||||
};
|
};
|
||||||
|
|
||||||
const { mutateAsync } = useGetOrgTrialUrl();
|
const { mutateAsync } = useGetOrgTrialUrl();
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import { z } from "zod";
|
|||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, FormControl, Input } from "@app/components/v2";
|
import { Button, FormControl, Input } from "@app/components/v2";
|
||||||
import { useCreateSubOrganization } from "@app/hooks/api";
|
import { useCreateSubOrganization } from "@app/hooks/api";
|
||||||
import { GenericResourceNameSchema, slugSchema } from "@app/lib/schemas";
|
import { slugSchema } from "@app/lib/schemas";
|
||||||
|
|
||||||
type ContentProps = {
|
type ContentProps = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
|||||||
Reference in New Issue
Block a user