Add account self-delete and subscription lifecycle sync (#34) #39

Merged
westfarn merged 2 commits from feature/account-self-delete-and-subscription-mgmt into master 2026-08-01 12:24:17 -07:00
Owner

Summary

  • Closes #34
  • Companion for chat_web_app#75 (portal cancel/change local sync)
  • Soft-delete DELETE /api/user/ for the authenticated user only: deleted=True, is_active=False, hide conversations, blacklist outstanding refresh tokens; staff self-delete rejected
  • Stripe customer.subscription.updated / deleted webhooks sync plan status, cancel_at_period_end, and current_period_end; checkout assigns plan from metadata.plan_slug
  • UserAuthEvent audit: account_deleted, subscription_started (first active plan), subscription_updated (plan/status/cancel changes) — visible on user admin
  • Document FE contract in README (endpoint, response, post-delete logout)

Test plan

  • uv run python manage.py test chat_backend.tests.test_views_users.CustomUserSelfDeleteTestCase finance.tests
  • Authenticated DELETE /api/user/ soft-deletes self, hides conversations, blocks re-login, writes account_deleted auth event
  • Checkout / Backer assign writes subscription_started; portal cancel/change writes subscription_updated
  • Anonymous / staff self-delete rejected; body cannot target another user
  • After portal cancel, webhook sets cancel_at_period_end / canceled on GET /finance/subscription/
## Summary - Closes [#34](https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/34) - Companion for [chat_web_app#75](https://git.aimloperations.com/ai_ml_operations/chat_web_app/issues/75) (portal cancel/change local sync) - Soft-delete `DELETE /api/user/` for the authenticated user only: `deleted=True`, `is_active=False`, hide conversations, blacklist outstanding refresh tokens; staff self-delete rejected - Stripe `customer.subscription.updated` / `deleted` webhooks sync plan status, `cancel_at_period_end`, and `current_period_end`; checkout assigns plan from `metadata.plan_slug` - **UserAuthEvent audit**: `account_deleted`, `subscription_started` (first active plan), `subscription_updated` (plan/status/cancel changes) — visible on user admin - Document FE contract in README (endpoint, response, post-delete logout) ## Test plan - [ ] `uv run python manage.py test chat_backend.tests.test_views_users.CustomUserSelfDeleteTestCase finance.tests` - [ ] Authenticated `DELETE /api/user/` soft-deletes self, hides conversations, blocks re-login, writes `account_deleted` auth event - [ ] Checkout / Backer assign writes `subscription_started`; portal cancel/change writes `subscription_updated` - [ ] Anonymous / staff self-delete rejected; body cannot target another user - [ ] After portal cancel, webhook sets `cancel_at_period_end` / `canceled` on `GET /finance/subscription/`
westfarn added 1 commit 2026-08-01 12:15:17 -07:00
Add account self-delete and subscription lifecycle sync (#34)
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 9s
b3203f755d
Soft-delete DELETE /api/user/ for authenticated users (hide conversations,
blacklist tokens, block staff self-delete). Sync Stripe portal cancel/change
via subscription.updated/deleted webhooks and expose cancel_at_period_end for
Account UI (chat_web_app#75 companion).
westfarn added 1 commit 2026-08-01 12:21:55 -07:00
Log account delete and subscription changes in UserAuthEvent
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 10s
d01f3a2696
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.
westfarn merged commit eedc842b08 into master 2026-08-01 12:24:17 -07:00
westfarn deleted branch feature/account-self-delete-and-subscription-mgmt 2026-08-01 12:24:17 -07:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/chat_backend#39