fix(pos): cargar empleados reales en login en vez de datos demo

- Nuevo endpoint GET /pos/api/auth/employees/<tenant_id>
- Login carga empleados dinamicamente del tenant
- Si hay 1 solo empleado, se auto-selecciona
- Removidos 6 usuarios hardcodeados del design system

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 08:46:25 +00:00
parent 56fed52253
commit 7810005a57
2 changed files with 96 additions and 107 deletions

View File

@@ -157,6 +157,38 @@ def login_pin():
})
@auth_bp.route('/employees/<int:tenant_id>', methods=['GET'])
def list_login_employees(tenant_id):
"""Public endpoint: list employees for the login screen (names + roles only, no sensitive data)."""
try:
conn = get_tenant_conn(tenant_id)
except ValueError:
return jsonify({'error': 'Tenant not found'}), 404
cur = conn.cursor()
cur.execute("""
SELECT id, name, role FROM employees
WHERE is_active = true AND pin IS NOT NULL
ORDER BY name
""")
employees = []
for row in cur.fetchall():
name = row[1]
parts = name.split()
initials = ''.join([p[0].upper() for p in parts[:2]]) if parts else '?'
role_labels = {'owner': 'Dueño', 'admin': 'Administrador', 'cashier': 'Cajero', 'warehouse': 'Almacén', 'accountant': 'Contador'}
employees.append({
'id': row[0],
'name': name,
'initials': initials,
'role': row[2],
'role_label': role_labels.get(row[2], row[2])
})
cur.close()
conn.close()
return jsonify({'data': employees})
@auth_bp.route('/me', methods=['GET'])
def auth_me():
"""Get current employee info from token."""