Refactoring “Conciliación de líneas”: UI status card, auth hardening, and full project rename on Vercel
TL;DR: I renamed the repo from conciliación‑telcel to conciliación‑líneas, added a status‑card component to the front‑end, and upgraded the authentication flow to require user + password + PIN. The changes touch HTML, CSS, JS, several back‑end helpers and the deployment docs, making the app ready for production on Vercel.
The Problem
The original codebase was a quick prototype for a Telcel line‑reconciliation board. It suffered from three concrete issues that broke the production workflow:
- Branding leakage – The HTML title, README,
NOTICE, and several comments still referenced Telcel. Vercel deployments showed the old name, causing confusion for stakeholders. - Missing UI feedback – Users had no visual cue about the current reconciliation status (e.g., “Plan activo”, “Plan suspendido”). The UI only displayed a raw table, making it hard to spot problems.
- Weak authentication – The
api/auth/[action].jsendpoint only checked email + password. Business rules required an extra PIN for privileged actions, but the code never validated it, opening a security gap.
These problems manifested as:
Error: Uncaught TypeError: Cannot read property 'status' of undefined (app.js:73) when the front‑end tried to render a status that didn’t exist, and a security audit flagged the missing PIN check as “high severity”.
What I Tried First
My first attempt was a superficial rename:
# naive rename sed -i 's/Conciliación Telcel/Conciliación de líneas/g' README.md I updated the <title> tag in public/index.html but left the meta description, the NOTICE file, and the comment blocks untouched. The UI still referenced the old CSS class (.status-card) that didn’t exist, so the page threw a 404 on the stylesheet.
Next, I added a quick status badge directly in public/js/app.js:
const statusBadge = `<div class="badge">${status}</div>`; document.body.insertAdjacentHTML('beforeend', statusBadge); Because the CSS rule for .badge was missing, the badge rendered as plain text, offering no visual distinction.
Finally, I tried to inject PIN validation by appending a check in api/auth/[action].js:
if (pin !== expectedPin) throw new Error('Invalid PIN'); But the expectedPin variable was never defined, causing a ReferenceError and breaking every login attempt.
All three approaches failed because they touched only one layer of the stack, leaving other layers inconsistent.
The Implementation
Below is the final, end‑to‑end change set that solved the three problems. I kept the diff snippets from the commits to show exactly what was modified.
1. Full project rename
README.md and NOTICE were updated to reflect the new name:
-# Conciliación Telcel +# Conciliación de líneas -conciliacion-telcel +conciliacion-lineas The package.json name field was also adjusted (not shown in the diff but required for Vercel):
{ "name": "conciliacion-lineas", ... } 2. UI status card
CSS – public/css/app.css
Added a minimal card style and removed a stray padding typo:
-.tabs button{font:600 14px system-ui;padding:9px 14p +.tabs button{font:600 14px system-ui;padding:9px 14px} +.status-card{ + background:#f5f5f5; + border-radius:4px; + padding:12px; + margin-top:16px; + font-weight:600; +} HTML – public/index.html
Inserted a placeholder <div id="status-card"></div> right after the main heading:
-<title>Conciliación de líneas</title> +<title>Conciliación de líneas</title> ... +<div id="status-card"></div> JS – public/js/app.js
Implemented the card rendering logic, pulling the status from the API response (reconStatus):
@@ -67,7 +67,13 @@ const statusMap = { plord: "Mismo plan, palabras en otro orden", estf: "Valor no estándar (debe ser Activa o Suspendida)", - plazo: "“Tiempo Contrato” no coincide con los meses restantes", + plazo: "“Tiempo Contrato” no coincide con los meses restantes", }; + // New status‑card rendering + const renderStatusCard = (status) => { + const card = `<div class="status-card">Current status: <strong>${status}</strong></div>`; + document.getElementById('status-card').innerHTML = card; + }; + // Existing code that fetches reconciliation data... fetch('/api/data/getStatus') .then(r => r.json()) - .then(data => console.log(data)); + .then(data => { + renderStatusCard(data.reconStatus); + }) .catch(err => console.error(err)); Now the UI shows a colored card with the current reconciliation status, and the CSS ensures it’s visually distinct.
3. Hardened authentication (email + password + PIN)
Back‑end – api/auth/[action].js
Added PIN verification, pulled from the users table, and improved the audit query:
diff @@ -12,12 +12,18 @@ async function notifyNewNetwork(u, ipAddr) { const known = await db.query(` - select count(*) from audit_log where target = ${u.email} and action = 'login_ok' and at > now() - interval '90 days'`); + select count(*) from audit_log where target = $1 and action = 'login_ok' and at > now() - interval '90 days'`, + [u.email]); if (known > 0 || any === 0 @@ -16,9 +22,20 @@ async function notifyNewNetwork(u, ipAddr) { // ---- NEW PIN CHECK ------------------------------------------------- - if (pin !== expectedPin) throw new Error('Invalid PIN'); + const pinRow = await db.query( + `select pin_hash from users where email = $1`, + [u.email] + ); + if (!pinRow.rowCount) throw new Error('User not found'); + const isValidPin = await crypto.compareHash(pin, pinRow.rows[0].pin_hash); + if (!isValidPin) { + await db.query( + `insert into audit_log (target, action, ip) values ($1, 'login_failed_pin', $2)`, + [u.email, ipAddr] + --- *Part of my [Build in Public](https://dev.to/zaerohell) series — sharing the real process of building SaaS projects from Playa del Carmen, México.* *Repo: `zaerohell/conciliacion-lineas` · 2026-12-04* \#playadev #buildinpublic