Remove tenant UI; restrict machine links to non-admin users; polish Users/Machines UX

This commit is contained in:
codex-bot 2025-10-21 11:55:05 -03:00
parent 4a30a1b564
commit 347609a186
3 changed files with 54 additions and 87 deletions

View file

@ -1088,6 +1088,10 @@ export const linkUser = mutation({
.withIndex("by_tenant_email", (q) => q.eq("tenantId", tenantId).eq("email", normalized))
.first()
if (!user) throw new ConvexError("Usuário não encontrado")
const role = (user.role ?? "").toUpperCase()
if (role === 'ADMIN' || role === 'AGENT') {
throw new ConvexError('Usuários administrativos não podem ser vinculados a máquinas')
}
const current = new Set<Id<"users">>(machine.linkedUserIds ?? [])
current.add(user._id)