Creating a CRM Super Admin
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user