diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index 289491e8d..3ffc2e203 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -57,7 +57,7 @@ type TOrgServiceFactoryDep = {
projectDAL: TProjectDALFactory;
projectMembershipDAL: Pick;
projectKeyDAL: Pick;
- orgMembershipDAL: Pick;
+ orgMembershipDAL: Pick;
incidentContactDAL: TIncidentContactsDALFactory;
samlConfigDAL: Pick;
smtpService: TSmtpService;
@@ -379,7 +379,10 @@ export const orgServiceFactory = ({
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId);
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.userId === userId)
throw new BadRequestError({ message: "Cannot update own organization membership" });
diff --git a/frontend/src/views/Org/UserPage/UserPage.tsx b/frontend/src/views/Org/UserPage/UserPage.tsx
index eb8b8e8e1..2858d97df 100644
--- a/frontend/src/views/Org/UserPage/UserPage.tsx
+++ b/frontend/src/views/Org/UserPage/UserPage.tsx
@@ -16,7 +16,12 @@ import {
Tooltip,
UpgradePlanModal
} 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 {
useDeleteOrgMembership,
@@ -31,7 +36,10 @@ export const UserPage = withPermission(
() => {
const router = useRouter();
const membershipId = router.query.membershipId as string;
+ const { user } = useUser();
const { currentOrg } = useOrganization();
+
+ const userId = user?.id || "";
const orgId = currentOrg?.id || "";
const { data: membership } = useGetOrgMembership(orgId, membershipId);
@@ -115,116 +123,118 @@ export const UserPage = withPermission(
? `${membership.user.firstName} ${membership.user.lastName}`
: "-"}
-
-
-
-
-
-
-
-
-
-
- {(isAllowed) => (
-
- handlePopUpOpen("orgMembership", {
- membershipId: membership.id,
- role: membership.role
- })
- }
- disabled={!isAllowed}
- >
- Edit User
-
- )}
-
-
- {(isAllowed) => (
- {
- if (currentOrg?.scimEnabled) {
- createNotification({
- text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
- type: "error"
- });
- return;
+ {userId !== membership.user.id && (
+
+
+
+
+
+
+
+
+
+
+ {(isAllowed) => (
+
+ handlePopUpOpen("orgMembership", {
+ membershipId: membership.id,
+ role: membership.role
+ })
}
-
- if (!membership.isActive) {
- // activate user
- await updateOrgMembership({
- organizationId: orgId,
- membershipId,
- isActive: true
- });
-
- return;
+ disabled={!isAllowed}
+ >
+ Edit User
+
+ )}
+
+
+ {(isAllowed) => (
+ {
+ if (currentOrg?.scimEnabled) {
+ createNotification({
+ text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
+ type: "error"
+ });
+ return;
+ }
- // deactivate user
- handlePopUpOpen("deactivateMember", {
- orgMembershipId: membershipId,
- username: membership.user.username
- });
- }}
- disabled={!isAllowed}
- >
- {`${membership.isActive ? "Deactivate" : "Activate"} User`}
-
- )}
-
-
- {(isAllowed) => (
- {
- if (currentOrg?.scimEnabled) {
- createNotification({
- text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
- type: "error"
+ if (!membership.isActive) {
+ // activate user
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId,
+ isActive: true
+ });
+
+ return;
+ }
+
+ // deactivate user
+ handlePopUpOpen("deactivateMember", {
+ orgMembershipId: membershipId,
+ username: membership.user.username
});
- return;
- }
+ }}
+ disabled={!isAllowed}
+ >
+ {`${membership.isActive ? "Deactivate" : "Activate"} User`}
+
+ )}
+
+
+ {(isAllowed) => (
+ {
+ if (currentOrg?.scimEnabled) {
+ createNotification({
+ text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
+ type: "error"
+ });
+ return;
+ }
- handlePopUpOpen("removeMember", {
- orgMembershipId: membershipId,
- username: membership.user.username
- });
- }}
- disabled={!isAllowed}
- >
- Remove User
-
- )}
-
-
-
+ handlePopUpOpen("removeMember", {
+ orgMembershipId: membershipId,
+ username: membership.user.username
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Remove User
+
+ )}
+
+
+
+ )}
diff --git a/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectsSection.tsx b/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectsSection.tsx
index ffd118abf..dabc97c5f 100644
--- a/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectsSection.tsx
+++ b/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectsSection.tsx
@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
import { DeleteActionModal, IconButton } from "@app/components/v2";
-import { useOrganization,useUser } from "@app/context";
+import { useOrganization, useUser } from "@app/context";
import { useDeleteUserFromWorkspace, useGetOrgMembership } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -51,7 +51,7 @@ export const UserProjectsSection = ({ membershipId }: Props) => {
Projects
- {userId !== membership.user.id && (
+ {userId !== membership.user.id && Boolean(membership.user.publicKey) && (