fix(auth): repair TOTP CI failures

Address the migration and formatting failures reported on the TOTP branch.

Migrations
- Register totp_credentials and totp_recovery_codes in
  _ALEMBIC_TENANT_TABLES. On a legacy PostgreSQL install these two tables
  reference users.uuid, which only exists after 0009, so create_all() must
  not run ahead of Alembic the way it did for the other tenant tables.
  Without this the PostgreSQL migration test failed with
  "column uuid referenced in foreign key constraint does not exist".

Tests
- Resolve the Alembic head dynamically in the RAG document identity
  regression instead of pinning 0025_rag_document_identity. The TOTP and
  RAG branches now meet at a merge revision, so the pinned value was no
  longer the head. This matches the convention already used by
  test_migrations_postgres.

Formatting
- Apply ruff format to the new backend modules and prettier to the locale
  files and TOTP components, so the lint jobs pass.
This commit is contained in:
TyperBody
2026-09-24 01:31:54 +08:00
parent 8633567ce7
commit 28e8821365
18 changed files with 431 additions and 292 deletions
@@ -817,9 +817,7 @@ class UserRouterGroup(group.RouterGroup):
rotate = bool(json_data.get('rotate', False))
try:
enrollment = await self.ap.totp_service.begin_enrollment(
account.uuid, account.user, rotate=rotate
)
enrollment = await self.ap.totp_service.begin_enrollment(account.uuid, account.user, rotate=rotate)
except totp_module.TotpError as e:
return self.http_status(409, e.code, str(e))
@@ -985,9 +983,7 @@ class UserRouterGroup(group.RouterGroup):
return self.http_status(404, 'account_not_found', 'Account not found')
try:
enrollment = await self.ap.totp_service.begin_enrollment(
target_account_uuid, target.user, force=True
)
enrollment = await self.ap.totp_service.begin_enrollment(target_account_uuid, target.user, force=True)
except totp_module.TotpError as e:
return self.http_status(409, e.code, str(e))