feat: app de alumnos sin contraseña (invitación de un solo uso, avisos de falta y pagos informados)

- Acceso del alumno o tutor con link de un solo uso (hash SHA-256, consumo
  atómico, el GET no consume), sesión propia de 90 días deslizante, passkeys
  opcionales (SimpleWebAuthn) y mail de recuperación con rate limit.
- Lado alumno (/i/:token, /acceso, /alumno/*): inicio, clases, avisar falta,
  pagos, informar pago con comprobante (S3 privado, magic bytes) y perfil.
- Lado profe: acceso a la app en la ficha del alumno (invitar/reinvitar),
  "Pagos para verificar" en Cobros con badge, faltas avisadas en la ficha de
  grupo y datos para transferir en Ajustes.
- "Requiere atención" y el recordatorio de WhatsApp excluyen cuotas informadas.
- Zona horaria por defecto: Buenos Aires.
- Migración add_student_access, tests contra Postgres real (test:db) y docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-28 15:39:09 -03:00
parent b99bc4d519
commit 060a4f09e4
146 changed files with 7994 additions and 32 deletions

View File

@@ -0,0 +1,36 @@
import {
type ConfirmRecoveryEmail as ConfirmRecoveryEmailInput,
ConfirmRecoveryEmailSchema,
type SetRecoveryEmail as SetRecoveryEmailInput,
SetRecoveryEmailSchema,
} from '@gruperly/shared';
import { Hono } from 'hono';
import type { BackendEnv } from '@/http/env';
import { problemJson, resultJson } from '@/http/problem-details';
import { validate } from '@/http/validate';
import { currentStudent, studentSession } from '../../middleware';
import { GetStudentMe } from '../me/use-case';
import { ConfirmRecoveryEmail, RemoveRecoveryEmail, SetRecoveryEmail } from './use-case';
const route = new Hono<BackendEnv>();
route.put('/me/recovery-email', studentSession, validate.json(SetRecoveryEmailSchema), async (c) => {
const { accountId } = currentStudent(c);
const { email } = c.req.valid('json') as SetRecoveryEmailInput;
const result = await new SetRecoveryEmail().execute(accountId, email);
if (!result.ok) return problemJson(c, result.error);
return resultJson(c, await new GetStudentMe().execute(accountId));
});
route.delete('/me/recovery-email', studentSession, async (c) => {
const { accountId } = currentStudent(c);
await new RemoveRecoveryEmail().execute(accountId);
return resultJson(c, await new GetStudentMe().execute(accountId));
});
route.post('/recovery-email/confirm', validate.json(ConfirmRecoveryEmailSchema), async (c) => {
const { token } = c.req.valid('json') as ConfirmRecoveryEmailInput;
return resultJson(c, await new ConfirmRecoveryEmail().execute(token));
});
export default route;