feat: more ui improvements

This commit is contained in:
=
2025-11-08 19:39:23 +05:30
parent 43c23bfa12
commit 8fe979ecc6
10 changed files with 63 additions and 11 deletions

View File

@@ -230,7 +230,7 @@ export const identityV2ServiceFactory = ({
const { scopeData } = dto;
const factory = scopeFactory[scopeData.scope];
await factory.onListIdentityGuard(dto);
const isIdentityAccessible = await factory.onListIdentityGuard(dto);
const identities = await identityDAL.listIdentities(dto.scopeData, {
search: dto.data.search,
@@ -238,7 +238,7 @@ export const identityV2ServiceFactory = ({
limit: dto.data.limit
});
return identities;
return { ...identities, docs: identities.docs.filter((el) => isIdentityAccessible({ identityId: el.id })) };
};
return {

View File

@@ -5,7 +5,7 @@ export interface TIdentityV2Factory {
onCreateIdentityGuard: (arg: TCreateIdentityV2DTO) => Promise<void>;
onUpdateIdentityGuard: (arg: TUpdateIdentityV2DTO) => Promise<void>;
onDeleteIdentityGuard: (arg: TDeleteIdentityV2DTO) => Promise<void>;
onListIdentityGuard: (arg: TListIdentityV2DTO) => Promise<void>;
onListIdentityGuard: (arg: TListIdentityV2DTO) => Promise<(arg: { identityId: string }) => boolean>;
onGetIdentityByIdGuard: (arg: TGetIdentityByIdV2DTO) => Promise<void>;
getScopeField: (scope: AccessScopeData) => { key: "orgId" | "namespaceId" | "projectId"; value: string };
}

View File

@@ -65,6 +65,8 @@ export const newOrgIdentityFactory = ({ permissionService }: TOrgIdentityFactory
scope: OrganizationActionScope.Any
});
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return () => true;
};
const onGetIdentityByIdGuard: TIdentityV2Factory["onGetIdentityByIdGuard"] = async (dto) => {

View File

@@ -81,6 +81,12 @@ export const newProjectIdentityFactory = ({ permissionService }: TProjectIdentit
ProjectPermissionIdentityActions.Read,
ProjectPermissionSub.Identity
);
return (arg) =>
permission.can(
ProjectPermissionIdentityActions.Read,
subject(ProjectPermissionSub.Identity, { identityId: arg.identityId })
);
};
const onGetIdentityByIdGuard: TIdentityV2Factory["onGetIdentityByIdGuard"] = async (dto) => {

View File

@@ -6,7 +6,7 @@ export interface TMembershipIdentityScopeFactory {
onUpdateMembershipIdentityGuard: (arg: TUpdateMembershipIdentityDTO) => Promise<void>;
onDeleteMembershipIdentityGuard: (arg: TDeleteMembershipIdentityDTO) => Promise<void>;
onListMembershipIdentityGuard: (arg: TListMembershipIdentityDTO) => Promise<void>;
onListMembershipIdentityGuard: (arg: TListMembershipIdentityDTO) => Promise<(arg: { identityId: string }) => boolean>;
onGetMembershipIdentityByIdentityIdGuard: (arg: TGetMembershipIdentityByIdentityIdDTO) => Promise<void>;
getScopeField: (scope: AccessScopeData) => { key: "orgId" | "namespaceId" | "projectId"; value: string };
getScopeDatabaseFields: (scope: AccessScopeData) => {

View File

@@ -180,6 +180,8 @@ export const newOrgMembershipIdentityFactory = ({
scope: OrganizationActionScope.Any
});
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return () => true;
};
const onGetMembershipIdentityByIdentityIdGuard: TMembershipIdentityScopeFactory["onGetMembershipIdentityByIdentityIdGuard"] =

View File

@@ -194,6 +194,12 @@ export const newProjectMembershipIdentityFactory = ({
ProjectPermissionIdentityActions.Read,
ProjectPermissionSub.Identity
);
return (arg) =>
permission.can(
ProjectPermissionIdentityActions.Read,
subject(ProjectPermissionSub.Identity, { identityId: arg.identityId })
);
};
const onGetMembershipIdentityByIdentityIdGuard: TMembershipIdentityScopeFactory["onGetMembershipIdentityByIdentityIdGuard"] =