Il repo resta al sito: app in radice, piattaforme nel loro repo

apps/sito passa in radice, apps/platforms si toglie: vive in
gitea:Adriano/InsanityLab-platforms, con la storia del repo comune. I piani e
le specifiche di Longevity e Campus lasciano docs/ e seguono le piattaforme.
README e compose: deploy da /opt/docker/insanitylab/src; al primo deploy .env
va spostato da apps/sito/.env alla radice.

Refs #20

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-29 14:25:12 +00:00
parent 9efd9a7680
commit 3fff3cd2f8
608 changed files with 14 additions and 104131 deletions
@@ -0,0 +1,32 @@
import type { APIRoute } from 'astro';
import { getDb } from '../../../../../lib/db';
import { getUserById, updateUserPassword, hashPassword, randomPassword } from '../../../../../lib/auth';
export const prerender = false;
const json = (status: number, body: object) =>
new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });
/**
* Cambia la password di un utente. Senza corpo la genera a caso; con `{ password }` usa
* quella scelta dall'admin. In entrambi i casi la risposta la riporta in chiaro una volta
* sola: nel database finisce solo il suo hash.
*/
export const POST: APIRoute = async ({ params, request }) => {
const id = Number(params.id);
if (!getUserById(getDb(), id)) return json(404, { error: 'Utente inesistente.' });
let scelta = '';
if (request.headers.get('content-type')?.includes('application/json')) {
try {
const data = (await request.json()) as { password?: unknown };
scelta = String(data.password ?? '');
} catch {
return json(400, { error: 'Richiesta non valida.' });
}
}
if (scelta && scelta.length < 8) return json(400, { error: 'Password troppo corta (min 8).' });
const password = scelta || randomPassword();
updateUserPassword(getDb(), id, hashPassword(password));
return json(200, { password });
};