Summary#
routes/auth.rs— extractsrequire_admin_token()to replace the 37-line Bearer token auth block that was copy-pasted verbatim intoclaim_codes,create_account, andcreate_signing_key; also fixes a pre-existing inconsistency increate_signing_keywhereinspect_errdebug logging for non-UTF-8 auth headers was missingroutes/code_gen.rs— movesgenerate_code()+CODE_LEN/CHARSETconstants here fromclaim_codesandcreate_account, where they were defined identicallyroutes/test_utils.rs— sharestest_state_with_admin_token()instead of duplicating it in each route's test modulecreate_account— consolidates 4 pre-check uniqueness queries into 2OR EXISTSqueries (email and handle each now check bothaccounts+pending_accountsin a single round-trip); the cross-table checks remain load-bearing since SQLite has no cross-table FK enforcement
Net: 121 insertions, 187 deletions. All 185 tests pass.
Test plan#
-
cargo testpasses (185 tests, 0 failures) - Auth: missing/wrong/bare token still returns 401 on all three admin endpoints
-
POST /v1/accountsstill returns 409 for email duplicate inaccountstable (cross-table check preserved) -
POST /v1/accountsstill returns 409 for handle duplicate inhandlestable (cross-table check preserved)