mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 17:28:26 +00:00
Patch for update org membership call, hide edit user on self user page
This commit is contained in:
@@ -57,7 +57,7 @@ type TOrgServiceFactoryDep = {
|
|||||||
projectDAL: TProjectDALFactory;
|
projectDAL: TProjectDALFactory;
|
||||||
projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findProjectMembershipsByUserId" | "delete">;
|
projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findProjectMembershipsByUserId" | "delete">;
|
||||||
projectKeyDAL: Pick<TProjectKeyDALFactory, "find" | "delete">;
|
projectKeyDAL: Pick<TProjectKeyDALFactory, "find" | "delete">;
|
||||||
orgMembershipDAL: Pick<TOrgMembershipDALFactory, "findOrgMembershipById">;
|
orgMembershipDAL: Pick<TOrgMembershipDALFactory, "findOrgMembershipById" | "findOne">;
|
||||||
incidentContactDAL: TIncidentContactsDALFactory;
|
incidentContactDAL: TIncidentContactsDALFactory;
|
||||||
samlConfigDAL: Pick<TSamlConfigDALFactory, "findOne" | "findEnforceableSamlCfg">;
|
samlConfigDAL: Pick<TSamlConfigDALFactory, "findOne" | "findEnforceableSamlCfg">;
|
||||||
smtpService: TSmtpService;
|
smtpService: TSmtpService;
|
||||||
@@ -379,7 +379,10 @@ export const orgServiceFactory = ({
|
|||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
|
||||||
|
|
||||||
const [foundMembership] = await orgDAL.findMembership({ id: membershipId, orgId });
|
const foundMembership = await orgMembershipDAL.findOne({
|
||||||
|
id: membershipId,
|
||||||
|
orgId
|
||||||
|
});
|
||||||
if (!foundMembership) throw new NotFoundError({ message: "Failed to find organization membership" });
|
if (!foundMembership) throw new NotFoundError({ message: "Failed to find organization membership" });
|
||||||
if (foundMembership.userId === userId)
|
if (foundMembership.userId === userId)
|
||||||
throw new BadRequestError({ message: "Cannot update own organization membership" });
|
throw new BadRequestError({ message: "Cannot update own organization membership" });
|
||||||
|
|||||||
@@ -16,7 +16,12 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
UpgradePlanModal
|
UpgradePlanModal
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
|
import {
|
||||||
|
OrgPermissionActions,
|
||||||
|
OrgPermissionSubjects,
|
||||||
|
useOrganization,
|
||||||
|
useUser
|
||||||
|
} from "@app/context";
|
||||||
import { withPermission } from "@app/hoc";
|
import { withPermission } from "@app/hoc";
|
||||||
import {
|
import {
|
||||||
useDeleteOrgMembership,
|
useDeleteOrgMembership,
|
||||||
@@ -31,7 +36,10 @@ export const UserPage = withPermission(
|
|||||||
() => {
|
() => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const membershipId = router.query.membershipId as string;
|
const membershipId = router.query.membershipId as string;
|
||||||
|
const { user } = useUser();
|
||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
|
|
||||||
|
const userId = user?.id || "";
|
||||||
const orgId = currentOrg?.id || "";
|
const orgId = currentOrg?.id || "";
|
||||||
|
|
||||||
const { data: membership } = useGetOrgMembership(orgId, membershipId);
|
const { data: membership } = useGetOrgMembership(orgId, membershipId);
|
||||||
@@ -115,6 +123,7 @@ export const UserPage = withPermission(
|
|||||||
? `${membership.user.firstName} ${membership.user.lastName}`
|
? `${membership.user.firstName} ${membership.user.lastName}`
|
||||||
: "-"}
|
: "-"}
|
||||||
</p>
|
</p>
|
||||||
|
{userId !== membership.user.id && (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild className="rounded-lg">
|
<DropdownMenuTrigger asChild className="rounded-lg">
|
||||||
<div className="hover:text-primary-400 data-[state=open]:text-primary-400">
|
<div className="hover:text-primary-400 data-[state=open]:text-primary-400">
|
||||||
@@ -225,6 +234,7 @@ export const UserPage = withPermission(
|
|||||||
</OrgPermissionCan>
|
</OrgPermissionCan>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div className="mr-4 w-96">
|
<div className="mr-4 w-96">
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ export const UserProjectsSection = ({ membershipId }: Props) => {
|
|||||||
<div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
<div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
<div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
|
<div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
|
||||||
<h3 className="text-lg font-semibold text-mineshaft-100">Projects</h3>
|
<h3 className="text-lg font-semibold text-mineshaft-100">Projects</h3>
|
||||||
{userId !== membership.user.id && (
|
{userId !== membership.user.id && Boolean(membership.user.publicKey) && (
|
||||||
<IconButton
|
<IconButton
|
||||||
ariaLabel="copy icon"
|
ariaLabel="copy icon"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
|
|||||||
Reference in New Issue
Block a user