Files
wekan/server/lib/userErasureRun.js
T
Lauri Ojansivu 5dff6c0ec9 Erasing a person removes their data from every collection the inventory lists, on deletion and on anonymisation.
Deleting an account removed only the users document and its board, card and
list memberships; 40 collections the personal-data inventory marks for
deletion or anonymisation kept the person - workload, time entries, sign-in
addresses, sessions, jobs, credentials, notifications, reactions, event-log
tallies. models/lib/userErasure.js holds a rule per collection and runs on
deletion (Users.after.remove) and anonymisation (anonymizeUser); an invoiced
time entry is kept without the person, and an anonymised account keeps its
references. Integrity-checked delivery records are reduced to ids by their
compaction, which the inventory now names. Anonymisation replaces services
whole and clears sign-in addresses, passkeys, SQRL, push and ntfy, e-mail to
card and the e-mail buffer. The inventory's gap list is empty
(docs/Compliance/README.md WP-4).

Thanks to xet7 !
2026-11-24 01:57:13 +02:00

17 lines
866 B
JavaScript

// Runs the erasure rules of models/lib/userErasure.js against the database:
// on account deletion (models/users.js, Users.after.remove) and on
// anonymisation (server/models/users.js, anonymizeUser). The rules name
// collections, some of them server-only modules, so they are reached through
// the driver by name rather than by importing every model here.
import { MongoInternals } from 'meteor/mongo';
const { buildUserErasure, applyUserErasure } = require('/models/lib/userErasure');
export async function runUserErasure(user, mode) {
const rules = buildUserErasure(user, mode);
if (!rules) return {};
const db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
return applyUserErasure(rules, name => db.collection(name), (collection, error) =>
console.error(`[userErasure] ${mode} of ${user._id}: ${collection} not erased:`, error));
}