diff --git a/services/platform-api/src/tenants/tenants.service.ts b/services/platform-api/src/tenants/tenants.service.ts index 01af6c8..f65be0d 100644 --- a/services/platform-api/src/tenants/tenants.service.ts +++ b/services/platform-api/src/tenants/tenants.service.ts @@ -14,7 +14,7 @@ import { PricesService } from '../prices/prices.service.js' import type { PriceCurrency, PriceCycle, PriceDocument } from '../schemas/price.schema.js' import { Subscription, SubscriptionDocument } from '../schemas/subscription.schema.js' import { Tenant, TenantDocument } from '../schemas/tenant.schema.js' -import { User, UserDocument } from '../schemas/user.schema.js' +import { User, UserDocument, roleForTenant } from '../schemas/user.schema.js' import type { PartnerUpdateTenantDto } from '../me/dto/partner-update-tenant.dto.js' import type { CreateTenantDto } from './dto/create-tenant.dto.js' import type { UpdateBillingInfoDto } from './dto/update-billing-info.dto.js' @@ -341,7 +341,15 @@ export class TenantsService { enrolled = false } } - return { id: String(u._id), name: u.name, email: u.email, role: u.role, enrolled } + // Tenant-scoped role, not the global fallback — a user who is admin + // here but member elsewhere must read 'admin' in this list. + return { + id: String(u._id), + name: u.name, + email: u.email, + role: roleForTenant(u, tenant._id), + enrolled, + } }), ) return {