fix: vendedor accede a invitaciones trial (no invitar cliente)

This commit is contained in:
Horux Dev
2026-06-22 23:06:39 +00:00
parent cc002adbd2
commit a1727321c3
4 changed files with 12 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ import { z } from 'zod';
import * as tenantsService from '../services/tenants.service.js';
import { AppError } from '../middlewares/error.middleware.js';
import { isGlobalAdmin } from '../utils/global-admin.js';
import { hasAnyPlatformRole } from '../utils/platform-admin.js';
import { isOwnerSomewhere } from '../utils/memberships.js';
async function requireGlobalAdmin(req: Request): Promise<void> {
@@ -13,8 +14,10 @@ async function requireGlobalAdmin(req: Request): Promise<void> {
export async function getAllTenants(req: Request, res: Response, next: NextFunction) {
try {
const isAdmin = await isGlobalAdmin(req.user!.tenantId, req.user!.role, req.user!.userId);
if (!isAdmin) {
// Admin global, TI y Vendedor pueden ver el listado completo de tenants.
// Vendedor lo necesita para enviar invitaciones de trial.
const canList = await hasAnyPlatformRole(req.user!.userId, 'platform_admin', 'platform_ti', 'platform_sales');
if (!canList) {
// Evita 403 en consola del frontend cuando componentes sin-gate hacen polling
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
return res.json([]);