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,49 @@
import type { Prisma } from '@generated/prisma/client';
export type StudentAccessDb = {
studentAccountAttendee: Prisma.StudentAccountAttendeeDelegate;
};
/* The authorization rule of every student endpoint: only the attendees linked
to the session's account. Anything else is a 404 (we don't confirm ids). */
export async function linkedAttendeeIds(db: StudentAccessDb, accountId: string): Promise<string[]> {
const links = await db.studentAccountAttendee.findMany({
// A DROPPED attendee loses access; a PAUSED one keeps it.
where: { accountId, attendee: { status: { not: 'DROPPED' } } },
select: { attendeeId: true },
orderBy: { createdAt: 'asc' },
});
return links.map((link) => link.attendeeId);
}
export type LinkedAttendeeDb = { attendee: Prisma.AttendeeDelegate };
/* One attendee of the session, with what the student screens need from the
group. null for an attendee not linked to the account (or DROPPED): routes
answer 404, the same as for an id that doesn't exist. */
export async function findLinkedAttendee(db: LinkedAttendeeDb, accountId: string, attendeeId: string) {
return db.attendee.findFirst({
where: {
id: attendeeId,
status: { not: 'DROPPED' },
studentAccounts: { some: { accountId } },
},
select: {
id: true,
fullName: true,
groupId: true,
group: {
select: {
id: true,
name: true,
days: true,
time: true,
createdById: true,
owner: { select: { name: true, country: true, transferAlias: true, transferHolder: true } },
},
},
},
});
}
export type LinkedAttendee = NonNullable<Awaited<ReturnType<typeof findLinkedAttendee>>>;