All checks were successful
CI / Lint, typecheck, test (push) Successful in 3m14s
CI / Build container images (push) Has been skipped
CD / Build and push images (push) Successful in 3m45s
CD / Deploy to Test (push) Successful in 10s
CD / Smoke tests against Test (push) Successful in 1m11s
CD / Promote to Int (push) Successful in 11s
CI / Auth e2e pack (push) Successful in 5m20s
CI / Import/export fidelity gate (push) Successful in 45s
New /admin/system panel (operations.md §Maintenance jobs): the maintenance job list shows every registered job with truthful last-run data (new Job.lastDurationMs recorded by the scheduler) and a manual trigger that respects the run-mutex and is itself audit-logged; a backup card mirrors the sidecar's status.json including the freshness verdict; an audit-log viewer filters by actor, action, and time range with pagination; and a storage overview lists the largest ponds. Auth events and admin actions (grants, members, user/quota admin, plugins, settings, setup) now land in a new audit_log table through a central AuditService — which keeps emitting the established stdout log line — while content activity stays log-only by design. All endpoints are Site-Admin-only; covered by API DB tests and a Playwright pack in CI. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { DELETED_USER_DISPLAY_NAME } from '@dorfteich/shared';
|
|
import { PinoLogger } from 'nestjs-pino';
|
|
|
|
import { AuditService } from '../audit/audit.service';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
|
|
/**
|
|
* GDPR account deletion (issue #59, security.md §Privacy). Rather than
|
|
* hard-deleting the user row — which would orphan or cascade authored content —
|
|
* this scrubs the personal data, drops the login credentials, and trashes the
|
|
* personal pond. The (kept) row is what `created_by`/authorship references, so
|
|
* shared content the user authored simply shows as "Deleted user".
|
|
*/
|
|
@Injectable()
|
|
export class PseudonymizationService {
|
|
constructor(
|
|
private readonly prisma: PrismaService,
|
|
private readonly audit: AuditService,
|
|
private readonly logger: PinoLogger,
|
|
) {
|
|
this.logger.setContext(PseudonymizationService.name);
|
|
}
|
|
|
|
async pseudonymize(userId: string): Promise<void> {
|
|
const marker = `deleted-${userId}`;
|
|
await this.prisma.$transaction(async (tx) => {
|
|
// Remove every login path (password + any linked identities).
|
|
await tx.userIdentity.deleteMany({ where: { userId } });
|
|
await tx.session.deleteMany({ where: { userId } });
|
|
await tx.user.update({
|
|
where: { id: userId },
|
|
data: {
|
|
username: marker,
|
|
email: `${marker}@deleted.invalid`,
|
|
displayName: DELETED_USER_DISPLAY_NAME,
|
|
status: 'DISABLED',
|
|
isSiteAdmin: false,
|
|
emailVerifiedAt: null,
|
|
},
|
|
});
|
|
// The personal pond follows the trash path (security.md §Privacy).
|
|
await tx.pond.updateMany({
|
|
where: { ownerId: userId, type: 'PERSONAL', deletedAt: null },
|
|
data: { deletedAt: new Date(), deletedBy: userId },
|
|
});
|
|
});
|
|
await this.audit.record({
|
|
action: 'user.pseudonymized',
|
|
targetType: 'user',
|
|
targetId: userId,
|
|
});
|
|
}
|
|
}
|