Start every Rule private, with a rotating link and files that follow its readers.

New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
This commit is contained in:
adilallo committed 2026-11-09 19:54:04 -07:00
1 parent 642551064c
commit 5cbda35e32
50 files changed
+2429 -219

No files matched your search

+4 -5
View File
@@ -11,15 +11,13 @@ import {
getSessionUser,
} from "../../../../lib/server/session";
import { apiRoute } from "../../../../lib/server/apiRoute";
import { deleteUploadsForUser } from "../../../../lib/server/uploads/deleteUploadedFiles";
/**
* Delete the signed-in user and associated data.
*
* **Policy (CR-86 / Ticket 15):** Prisma `User` deletion cascades `Session` and
* `RuleDraft`. `PublishedRule` uses `onDelete: SetNull` on `userId`, so published
* rules remain public with `userId = null` (anonymous/orphan rows) rather than
* being removed with the account. Change would require a schema migration if
* product later requires deleting all published rules with the user.
* Prisma `User` deletion cascades `Session`, `RuleDraft`, and `PublishedRule`
* (and uploads linked to those rows). Disk files are removed first.
*/
export const DELETE = apiRoute("user.me.delete", async () => {
if (!isDatabaseConfigured()) {
@@ -32,6 +30,7 @@ export const DELETE = apiRoute("user.me.delete", async () => {
}
try {
await deleteUploadsForUser(user.id);
await prisma.user.delete({ where: { id: user.id } });
} catch {
return internalError("Failed to delete account");