Let Cards players delete their account and read a privacy notice
Add a Compte section with a privacy notice and a confirmed deletion that anonymises the player row, erases their possessions and cancels open trades. The public contact comes from CARDS_PRIVACY_CONTACT, which production now requires before enabling the game. The admin E2E no longer relies on a pull from the previous test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
155187d01f
commit
e60fbd4e9b
16 changed files with 319 additions and 10 deletions
|
|
@ -7,6 +7,7 @@ import { CardsService, DEV_DISCORD_ID } from "./service.js";
|
|||
|
||||
const JSON_LIMIT = 64 * 1024;
|
||||
const DISCORD_TIMEOUT_MS = 10_000;
|
||||
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
|
||||
function bool(value, fallback = false) {
|
||||
if (value == null || value === "") return fallback;
|
||||
|
|
@ -131,12 +132,16 @@ export function createCardsApiHandler({
|
|||
// Cette connexion accorde les droits administrateur à n'importe quel visiteur.
|
||||
const devAuth = requestedDevAuth && (env.NODE_ENV !== "production" || allowProductionDevAuth);
|
||||
if (requestedDevAuth && !devAuth) console.error("CARDS_DEV_AUTH is ignored in production.");
|
||||
const configuredContact = String(env.CARDS_PRIVACY_CONTACT || "").trim();
|
||||
const privacyContact = EMAIL_PATTERN.test(configuredContact) ? configuredContact : null;
|
||||
let database = null;
|
||||
let service = null;
|
||||
if (enabled) {
|
||||
if (env.NODE_ENV === "production" && !env.CARDS_DB_PATH) throw new TypeError("CARDS_DB_PATH is required when Sokko TCG is enabled in production.");
|
||||
// Sans origine fixe, le retour OAuth et le contrôle CSRF dépendraient de l'en-tête Host envoyé par le client.
|
||||
if (env.NODE_ENV === "production" && !env.CARDS_PUBLIC_ORIGIN) throw new TypeError("CARDS_PUBLIC_ORIGIN is required when Sokko TCG is enabled in production.");
|
||||
// La notice de confidentialité doit indiquer à qui s'adresser avant d'ouvrir le jeu à de vrais comptes.
|
||||
if (env.NODE_ENV === "production" && !privacyContact) throw new TypeError("CARDS_PRIVACY_CONTACT must be a valid e-mail address when Sokko TCG is enabled in production.");
|
||||
const catalog = loadCardsCatalog(catalogPath);
|
||||
database = new CardsDatabase(databasePath);
|
||||
service = new CardsService({ database, catalog, now, random, devPerks });
|
||||
|
|
@ -179,7 +184,8 @@ export function createCardsApiHandler({
|
|||
enabled,
|
||||
devAuth: enabled && devAuth,
|
||||
discordConfigured: enabled && Boolean(env.DISCORD_CLIENT_ID && env.DISCORD_CLIENT_SECRET),
|
||||
catalog: enabled ? publicCatalog(service.catalog) : null
|
||||
catalog: enabled ? publicCatalog(service.catalog) : null,
|
||||
privacyContact: enabled ? privacyContact : null
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
|
@ -259,6 +265,12 @@ export function createCardsApiHandler({
|
|||
json(res, 200, { ok: true });
|
||||
return true;
|
||||
}
|
||||
if (req.method === "DELETE" && url.pathname === "/api/cards/account") {
|
||||
service.deleteAccount(session.player.id);
|
||||
res.setHeader("Set-Cookie", sessionCookie("", secureCookies, 0));
|
||||
json(res, 200, { ok: true });
|
||||
return true;
|
||||
}
|
||||
if (req.method === "GET" && url.pathname === "/api/cards/state") {
|
||||
json(res, 200, service.getState(session.player.id));
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue