feat: more review comments

This commit is contained in:
=
2025-10-10 00:09:48 +05:30
parent d2a6a47397
commit 9d204a66fd
16 changed files with 32 additions and 20 deletions
@@ -265,7 +265,7 @@ export const membershipGroupServiceFactory = ({
if (existingMembership.actorGroupId === dto.permission.id)
throw new BadRequestError({
message: "You can't delete you own membership"
message: "You can't delete your own membership"
});
const membershipDoc = await membershipGroupDAL.transaction(async (tx) => {
@@ -40,7 +40,7 @@ export const newOrgMembershipGroupFactory = ({
const onCreateMembershipGroupGuard: TMembershipGroupScopeFactory["onCreateMembershipGroupGuard"] = async () => {
throw new BadRequestError({
message: "Organizatin membership cannot be created for groups"
message: "Organization membership cannot be created for groups"
});
};
@@ -84,7 +84,7 @@ export const newOrgMembershipGroupFactory = ({
const onDeleteMembershipGroupGuard: TMembershipGroupScopeFactory["onDeleteMembershipGroupGuard"] = async () => {
throw new BadRequestError({
message: "Organizatin membership cannot be created for organization scoped group"
message: "Organization membership cannot be created for organization scoped group"
});
};
@@ -41,7 +41,7 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {
.leftJoin(TableName.Role, `${TableName.MembershipRole}.customRoleId`, `${TableName.Role}.id`)
.leftJoin(TableName.IdentityMetadata, (queryBuilder) => {
void queryBuilder
.on(`${TableName.Membership}.actorIdentityId`, `${TableName.IdentityMetadata}.userId`)
.on(`${TableName.Membership}.actorIdentityId`, `${TableName.IdentityMetadata}.identityId`)
.andOn(`${TableName.Membership}.scopeOrgId`, `${TableName.IdentityMetadata}.orgId`);
})
.where(`${TableName.Membership}.scopeOrgId`, scopeData.orgId)
@@ -272,7 +272,7 @@ export const membershipIdentityServiceFactory = ({
if (existingMembership.actorIdentityId === dto.permission.id)
throw new BadRequestError({
message: "You can't delete you own membership"
message: "You can't delete your own membership"
});
const membershipDoc = await membershipIdentityDAL.transaction(async (tx) => {
@@ -41,7 +41,7 @@ export const newOrgMembershipIdentityFactory = ({
const onCreateMembershipIdentityGuard: TMembershipIdentityScopeFactory["onCreateMembershipIdentityGuard"] =
async () => {
throw new BadRequestError({
message: "Organizatin membership cannot be created for organization scoped identity"
message: "Organization membership cannot be created for organization scoped identity"
});
};
@@ -88,7 +88,7 @@ export const newOrgMembershipIdentityFactory = ({
const onDeleteMembershipIdentityGuard: TMembershipIdentityScopeFactory["onDeleteMembershipIdentityGuard"] =
async () => {
throw new BadRequestError({
message: "Organizatin membership cannot be created for organization scoped identity"
message: "Organization membership cannot be created for organization scoped identity"
});
};
@@ -398,7 +398,7 @@ export const membershipUserServiceFactory = ({
if (existingMembership.actorUserId === dto.permission.id)
throw new BadRequestError({
message: "You can't delete you own membership"
message: "You can't delete your own membership"
});
const membershipDoc = await membershipUserDAL.transaction(async (tx) => {
+1 -1
View File
@@ -762,7 +762,7 @@ export const orgServiceFactory = ({
throw new NotFoundError({ message: `Organization membership with ID ${membershipId} not found` });
if (foundMembership.scopeOrgId !== orgId)
throw new UnauthorizedError({ message: "Updated org member doesn't belong to the organization" });
if (foundMembership.scopeOrgId === userId)
if (foundMembership.actorUserId === userId)
throw new UnauthorizedError({ message: "Cannot update own organization membership" });
const isCustomRole = !Object.values(OrgMembershipRole).includes(role as OrgMembershipRole);
@@ -106,6 +106,8 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
firstName,
lastName,
id: userId,
// akhilmhdh: if we do user encryption based join this would fail for scim user who haven't logged in yet
// public key is not used anymore as well
publicKey: "",
isGhost,
isOrgMembershipActive: isActive
@@ -249,7 +251,17 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
id,
userId,
projectId,
user: { email, username, firstName, lastName, id: userId, isGhost, publicKey: "" },
user: {
email,
username,
firstName,
lastName,
id: userId,
isGhost,
// akhilmhdh: if we do user encryption based join this would fail for scim user who haven't logged in yet
// public key is not used anymore as well
publicKey: ""
},
project: {
id: projectId,
name: projectName,
@@ -15,7 +15,6 @@ import { isCustomOrgRole } from "@app/services/org/org-role-fns";
import { TRoleScopeFactory } from "../role-types";
// TODO(simp): missing external group checking
type TOrgRoleScopeFactoryDep = {
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
externalGroupOrgRoleMappingDAL: Pick<TExternalGroupOrgRoleMappingDALFactory, "findOne">;
@@ -2395,8 +2395,8 @@ export const secretV2BridgeServiceFactory = ({
projectId: folder.projectId,
secretVersions: secretVersionsFilter,
findOpt: {
offset,
limit,
offset,
sort: [["createdAt", "desc"]]
}
});
@@ -221,7 +221,7 @@ export const secretVersionV2BridgeDALFactory = (db: TDbClient) => {
})
.orWhere((qb) => {
void qb.where(`${TableName.SecretVersionV2}.secretId`, secretId);
void qb.whereNull(`${TableName.Membership}.actorProjectId`);
void qb.whereNull(`${TableName.Membership}.scopeProjectId`);
if (secretVersions?.length) void qb.whereIn(`${TableName.SecretVersionV2}.version`, secretVersions);
})
.select(