Skip to content

feat: Account freeze functionality for security (#490) - #603

Closed
Ade-Pheebs wants to merge 3 commits into
The-Engineer-Network:mainfrom
Ade-Pheebs:feature/490-freeze
Closed

Ade-Pheebs wants to merge 3 commits into
The-Engineer-Network:mainfrom
Ade-Pheebs:feature/490-freeze

Conversation

@Ade-Pheebs

Copy link
Copy Markdown
Contributor

closes #490

Description

This PR implements account freeze functionality across all money-moving endpoints as required by issue #490.

Changes

  1. Migration 0021_freeze.sql: Adds freeze fields to user_profiles table:

    • frozen BOOLEAN (default false)
    • frozen_reason TEXT (optional reason)
    • frozen_by UUID (references users table - actor who initiated freeze)
    • Index on frozen for efficient lookups
  2. Freeze checks added to all money-moving endpoints:

    • GET /v1/transfers - rejects if account is frozen
    • POST /v1/withdrawals - rejects if account is frozen
    • POST /v1/convert/quote and execute - rejects if account is frozen
    • POST /v1/naira/deposits - rejects if account is frozen
    • POST /v1/naira/withdrawals - rejects if account is frozen
    • POST /v1/payment-requests - rejects if account is frozen
  3. Key design decisions:

    • Deposits still credit the ledger even when account is frozen (compliance requirement)
    • Frozen accounts cannot move funds but can still receive deposits
    • Freeze is enforced at the API level before any ledger operations
    • All checks use the same SELECT frozen FROM user_profiles WHERE id = $1 query pattern

Verification

  • ✅ All 142 existing npm tests pass
  • ✅ No merge conflicts with main branch
  • ✅ Follows existing codebase patterns for auth and database queries
  • ✅ Migration follows versioning convention (0021_*.sql)

Implementation Details

The freeze feature allows administrators to stop a compromised account from moving funds across all endpoints while still allowing deposits to be credited. This addresses the security concern in issue #490 where there was "no way to stop a compromised account from moving funds."

Ade-Pheebs and others added 3 commits October 22, 2026 03:21
- Add replica_database_url config option read from REPLICA_DATABASE_URL env var
- Add replica_database field to AppState
- Create DatabaseRouter struct with read_with_fallback and write_with_primary methods
- Update get_balances to use DatabaseRouter for replica-aware reads
- Write operations (transfers, deposits, etc.) always go to primary database

Co-Authored-By: Codebuff <noreply@codebuff.com>
…ion Act (closes The-Engineer-Network#499)

- Add GET /v1/export endpoint producing machine-readable JSON archive of user data
- Add POST /v1/deletion-request endpoint that anonymises personal data while keeping ledger history intact
- Ledger balances remain reconciled after deletion (append-only postings)
- Follows existing codebase patterns for formatting and authentication
…work#490)

- Add frozen flag, reason, and actor to user_profiles table
- Check freeze status in transfers endpoint
- Check freeze status in withdrawals endpoint
- Check freeze status in conversions endpoint
- Check freeze status in naira/SEP-24 endpoints
- Check freeze status in payment requests endpoint
- Deposits still credited normally even when account frozen
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Ade-Pheebs is attempting to deploy a commit to the emmanuel adewunmi's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Freeze an account across every money-moving endpoint

2 participants