feat: harden portal security and auditability

This commit is contained in:
Leon Tonhäuser committed 2026-08-10 21:46:54 +02:00
1 parent 7f1ecd9322
commit 21871bb9ff
26 files changed
+2664 -4

No files matched your search

+17 -1
View File
@@ -12,6 +12,7 @@ import {
} from "@/db/schema";
import type * as schema from "@/db/schema";
import type { AccountStatus } from "@/modules/auth/principal";
import { writeAudit } from "@/modules/audit/write";
import { mailer, type Mailer } from "@/modules/mail/mailer";
export type BillingAddressInput = {
@@ -121,7 +122,22 @@ export function createEditorialService({
},
async replaceBillingAddress(editorialId: string, input: BillingAddressInput): Promise<string> {
return repository.replaceBillingAddress({ editorialId, input: validateBillingAddress(input) });
const addressId = await repository.replaceBillingAddress({
editorialId,
input: validateBillingAddress(input),
});
try {
await writeAudit({
type: "billing_address_replaced",
actorType: "admin",
entityType: "editorial_account",
entityId: editorialId,
metadata: { addressId, countryCode: input.countryCode },
});
} catch {
// Audit is observability, not a transaction participant.
}
return addressId;
},
async transitionEditorialStatus(input: {