Log account delete and subscription changes in UserAuthEvent
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 10s

Add account_deleted, subscription_started, and subscription_updated
event types. Soft-delete, Checkout/Backer assign, and Stripe portal
lifecycle webhooks write audit rows visible on the user admin.
This commit is contained in:
2026-08-01 14:21:53 -05:00
parent b3203f755d
commit d01f3a2696
9 changed files with 206 additions and 9 deletions
+5 -1
View File
@@ -190,7 +190,7 @@ Push/merge to `master` auto-deploys **beta** only. Prod requires the Gitea
| Auth | JWT (authenticated user only; always deletes `request.user`) |
| Optional body | `{ "refresh_token": "<current refresh>" }` |
| Success | `200` `{ "detail": "Account deleted.", "deleted": true }` |
| Effects | Sets `deleted=True`, `is_active=False`; soft-deletes conversations; blacklists outstanding refresh tokens |
| Effects | Sets `deleted=True`, `is_active=False`; soft-deletes conversations; blacklists outstanding refresh tokens; logs `UserAuthEvent` `account_deleted` |
| Staff | Staff/superuser self-delete rejected (`400`, `code=staff_forbidden`) |
| Privacy v1 | Soft-delete only (no anonymization / hard purge) |
@@ -205,6 +205,10 @@ Plan change and cancel stay on Stripe Customer Portal
`GET /api/finance/subscription/` includes `cancel_at_period_end` and
`current_period_end` for Account UI messaging.
Subscription audit (`UserAuthEvent` on the user admin):
- `subscription_started` — first active plan (Checkout, Backer redeem, admin assign)
- `subscription_updated` — plan/status/cancel-at-period-end changes (portal + webhooks)
## Security note
Secrets previously hardcoded in `settings.py` (email password, captcha, Django