a414f03a59
- Configure tailscale serve automatically for each instance on Windows userspace networking. - Add local UI buttons: start/stop/reset/delete instances (stop/start preserve volumes). - Clean shutdown: stop tailscaled and instances, notify server with instance_stopped. - Restart tailscaled on agent boot using persisted state when pre-auth key is absent. - Sync instance stopped/deleted status to dashboard (server/lib/websocket.ts). - Security: include prior authz/scoping changes across API routes, ephemeral pre-auth keys, ACL policy, internal API key. - Update SUIVI_VPN_ONDEMAND.md and docs/ONBOARDING_CLIENT.md. - Bump agent version to 0.3.5.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { generateUniqueActivationCode } from "@/lib/activation";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const { searchParams } = new URL(req.url);
|
|
const classId = searchParams.get("classId");
|
|
const establishmentId = searchParams.get("establishmentId");
|
|
|
|
const where: any = {};
|
|
if (classId) where.classId = classId;
|
|
if (establishmentId) {
|
|
const classes = await prisma.class.findMany({ where: { establishmentId }, select: { id: true } });
|
|
where.classId = { in: classes.map((c) => c.id) };
|
|
}
|
|
|
|
const students = await prisma.student.findMany({
|
|
where,
|
|
include: { class: true, nodes: true },
|
|
orderBy: { createdAt: "desc" },
|
|
});
|
|
return NextResponse.json(students);
|
|
}
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const body = await req.json();
|
|
const { classId, firstName, lastName, email } = body;
|
|
const { code, expiresAt } = await generateUniqueActivationCode();
|
|
const student = await prisma.student.create({
|
|
data: {
|
|
classId,
|
|
firstName,
|
|
lastName,
|
|
email,
|
|
activationCode: code,
|
|
activationCodeExpiresAt: expiresAt,
|
|
},
|
|
});
|
|
return NextResponse.json(student, { status: 201 });
|
|
}
|