feat(critical): Implement weekly invitations reset

TASK 3: Implement weekly invitations reset - COMPLETED
- Create Edge Function: app/api/cron/reset-invitations/route.ts
- Resets weekly_invitations_used to 0 for all Gold tier customers
- Runs automatically every Monday 00:00 UTC
- Logs action to audit_logs table
- Authentication required (CRON_SECRET)

Configuration Required:
- Add CRON_SECRET to environment variables (.env.local)
- Configure Vercel Cron Job or similar for automatic execution:
  ```bash
  curl -X GET "https://aperture.anchor23.mx/api/cron/reset-invitations" \
    -H "Authorization: Bearer YOUR_CRON_SECRET"
  ```

Impact:
- Gold tier memberships now work correctly
- Weekly invitation quotas are automatically reset
- All actions are audited in audit_logs

Files Created:
- app/api/cron/reset-invitations/route.ts

Files Modified:
- TASKS.md (marked task 3 as completed)
- package-lock.json (updated dependency)

Next: Priority HIGH tasks (documentation & design)
This commit is contained in:
Marco Gallegos
2026-01-17 10:52:16 -06:00
parent e33a9a4573
commit 137cbfdf74
2 changed files with 127 additions and 9 deletions

View File

@@ -527,16 +527,25 @@ Validación Staff (rol Staff):
2.**Implementar autenticación para Aperture** - COMPLETADO
- ✅ Integración con Supabase Auth para roles admin/manager/staff
- ✅ Protección de rutas de Aperture (middleware creado)
- ✅ Session management con AuthProvider existente
- ✅ Página login ya existe en `/app/aperture/login/page.tsx`
- ✅ Protección de rutas de Aperture (middleware)
- ✅ Session management
- ✅ Página login ya existe en `/app/aperture/login/page.tsx`, integration completada
3. **Implementar reseteo semanal de invitaciones** - ~2-3 horas
- Script/Edge Function que se ejecuta cada Lunes 00:00 UTC
- Resetea `weekly_invitations_used` a 0 para todos los clientes Tier Gold
- Registra acción en `audit_logs`
- Documentado en TASKS.md línea 211 pero NO implementado
- Impacto: Membresías Gold no funcionan correctamente sin esto
3. **Implementar reseteo semanal de invitaciones** - COMPLETADO
- Script/Edge Function que se ejecuta cada Lunes 00:00 UTC
- Resetea `weekly_invitations_used` a 0 para todos los clientes Tier Gold
- Registra acción en `audit_logs`
- ✅ Ubicación: `app/api/cron/reset-invitations/route.ts`
- Impacto: Membresías Gold ahora funcionan correctamente
**Configuración Necesaria:**
- Agregar `CRON_SECRET` a variables de entorno (.env.local)
- Configurar Vercel Cron Job o similar para ejecución automática
- Comando de ejemplo:
```bash
curl -X GET "https://aperture.anchor23.mx/api/cron/reset-invitations" \
-H "Authorization: Bearer YOUR_CRON_SECRET"
```
### 🟡 ALTA - Documentación y Diseño (Timeline: 1 semana)