Creating a CRM Super Admin

This commit is contained in:
2026-09-19 21:54:21 +03:30
parent ff5ad21eb9
commit b016b4754f
28 changed files with 2977 additions and 6 deletions
@@ -20,7 +20,7 @@ export class MembershipsService {
async listActive(userId: string) {
return this.prisma.membership.findMany({
where: { userId, isActive: true },
where: { userId, isActive: true, organization: { isActive: true } },
include: {
organization: { select: { id: true, name: true } },
orgRole: { select: { name: true } },
@@ -35,12 +35,24 @@ export class MembershipsService {
): Promise<MembershipActor> {
const row = await this.prisma.membership.findFirst({
where: { userId, organizationId, isActive: true },
select: { userId: true, organizationId: true, role: true },
select: {
userId: true,
organizationId: true,
role: true,
organization: { select: { isActive: true } },
},
});
if (!row) {
throw new ForbiddenException('به این محیط دسترسی ندارید');
}
return row;
if (row.organization.isActive === false) {
throw new UnauthorizedException('این محیط غیرفعال است');
}
return {
userId: row.userId,
organizationId: row.organizationId,
role: row.role,
};
}
toChoices(