feat: added manageby and conditional rendering more items

This commit is contained in:
=
2025-10-20 18:58:43 +05:30
parent 8afc391e97
commit 8824be431f
11 changed files with 57 additions and 15 deletions
@@ -408,7 +408,7 @@ export const samlConfigServiceFactory = ({
});
}
} else if (dto.type === "orgSlug") {
const org = await orgDAL.findOne({ slug: dto.orgSlug });
const org = await orgDAL.findOne({ slug: dto.orgSlug, rootOrgId: null });
if (!org) {
throw new NotFoundError({
message: `Organization with slug '${dto.orgSlug}' not found`
@@ -393,7 +393,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
permissions: true,
description: true
}).optional(),
identity: IdentitiesSchema.pick({ name: true, id: true, hasDeleteProtection: true }).extend({
identity: IdentitiesSchema.pick({ name: true, id: true, hasDeleteProtection: true, orgId: true }).extend({
authMethods: z.array(z.string())
})
}).array(),
@@ -25,11 +25,12 @@ import { buildAuthMethods } from "../identity/identity-fns";
export type TIdentityProjectDALFactory = ReturnType<typeof identityProjectDALFactory>;
export const identityProjectDALFactory = (db: TDbClient) => {
const findByIdentityId = async (identityId: string, tx?: Knex) => {
const findByIdentityId = async (identityId: string, orgId: string, tx?: Knex) => {
try {
const docs = await (tx || db.replicaNode())(TableName.Membership)
.where(`${TableName.Membership}.actorIdentityId`, identityId)
.where(`${TableName.Membership}.scope`, AccessScope.Project)
.where(`${TableName.Membership}.scopeOrgId`, orgId)
.whereNotNull(`${TableName.Membership}.actorIdentityId`)
.join(TableName.Project, `${TableName.Membership}.scopeProjectId`, `${TableName.Project}.id`)
.join(TableName.Identity, `${TableName.Membership}.actorIdentityId`, `${TableName.Identity}.id`)
@@ -519,6 +519,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
db.ref("actorIdentityId").withSchema(TableName.Membership).as("identityId"),
db.ref("name").withSchema(TableName.Identity).as("identityName"),
db.ref("hasDeleteProtection").withSchema(TableName.Identity),
db.ref("orgId").withSchema(TableName.Identity).as("identityOrgId"),
db.ref("id").as("uaId").withSchema(TableName.IdentityUniversalAuth),
db.ref("id").as("gcpId").withSchema(TableName.IdentityGcpAuth),
@@ -570,6 +571,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
crPermission,
crName,
identityId,
identityOrgId,
identityName,
hasDeleteProtection,
role,
@@ -615,6 +617,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {
id: identityId as string,
name: identityName,
hasDeleteProtection,
orgId: identityOrgId,
authMethods: buildAuthMethods({
uaId,
alicloudId,
@@ -477,7 +477,7 @@ export const identityServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const identityMemberships = await identityProjectDAL.findByIdentityId(identityId);
const identityMemberships = await identityProjectDAL.findByIdentityId(identityId, actorOrgId);
return identityMemberships;
};