From 2607ca5ce3ab8d53efff253811dc91dc6fc4b948 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Sun, 19 Oct 2025 03:03:10 -0300 Subject: [PATCH] Assignee picker: return only ADMIN/AGENT (exclude collaborators/managers) --- convex/users.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/convex/users.ts b/convex/users.ts index 51c3c46..bc504df 100644 --- a/convex/users.ts +++ b/convex/users.ts @@ -2,7 +2,10 @@ import { mutation, query } from "./_generated/server"; import { ConvexError, v } from "convex/values"; import { requireAdmin } from "./rbac"; -const STAFF_ROLES = new Set(["ADMIN", "MANAGER", "AGENT", "COLLABORATOR"]); +// All roles that have staff-level access in some areas. Do NOT include COLLABORATOR here +// to avoid leaking collaborators into staff pickers such as "responsável". +const STAFF_ROLES = new Set(["ADMIN", "MANAGER", "AGENT"]); +const INTERNAL_STAFF_ROLES = new Set(["ADMIN", "AGENT"]); export const ensureUser = mutation({ args: { @@ -81,11 +84,9 @@ export const listAgents = query({ .withIndex("by_tenant", (q) => q.eq("tenantId", tenantId)) .collect(); + // Only internal staff (ADMIN/AGENT) should appear as responsáveis return users - .filter((user) => { - const normalizedRole = (user.role ?? "AGENT").toUpperCase(); - return STAFF_ROLES.has(normalizedRole); - }) + .filter((user) => INTERNAL_STAFF_ROLES.has((user.role ?? "AGENT").toUpperCase())) .sort((a, b) => a.name.localeCompare(b.name, "pt-BR")); }, });