Skip to content

fix(admin): restore the admin_auth import dropped in #332 - #338

Merged
MoltyCel merged 1 commit into
mainfrom
fix/restore-admin-auth-import
Sep 4, 2026
Merged

fix(admin): restore the admin_auth import dropped in #332#338
MoltyCel merged 1 commit into
mainfrom
fix/restore-admin-auth-import

Conversation

@MoltyCel

@MoltyCel MoltyCel commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Production fix. Every admin route is currently raising NameError at call time.

What happened

#332 removed the shadowed /identity/register-batch route. My deletion boundary looked for the next line starting with class , @app. or def — and the section banner plus this import sit before class AdminLoginRequest:

from app.admin_auth import (
    verify_password, create_session, verify_session,
    invalidate_session, ADMIN_USERS,
)

import app.main still succeeded. A missing name only raises when the line using it runs — so 677 tests stayed green while /admin/login, /admin/logout and the 18 routes behind _get_admin_session all failed on every call.

I checked after that deletion that AdminLoginRequest and _get_admin_session survived. I did not check what they call. That was the gap.

The test that closes it

tests/test_admin_auth_wiring.py exercises the routes rather than the module: unknown user → 401 not 500, known user with wrong password reaches verify_password, /admin/me and /admin/dashboard/overview → 401, /admin/logout does not raise, plus a direct assertion on all five names.

Negative control run: with the import removed again, all six fail. The tests catch this class of bug rather than merely passing alongside it.

Tests

6 new passed · full suite 693 passed.

🤖 Generated with Claude Code

#332 removed the shadowed /identity/register-batch route. The deletion boundary
searched for the next line starting with `class `, `@app.` or `def `, and the
section banner plus this import sit before `class AdminLoginRequest`, so they
went with it:

    from app.admin_auth import (
        verify_password, create_session, verify_session,
        invalidate_session, ADMIN_USERS,
    )

`import app.main` still succeeded — a missing name only raises when the line
using it runs. So the suite stayed green while every admin route failed at call
time with NameError: name 'verify_session' is not defined. Affected:
/admin/login (ADMIN_USERS, verify_password, create_session), /admin/logout
(invalidate_session), and the 18 routes behind _get_admin_session, including
the dashboard.

The check after that deletion confirmed AdminLoginRequest and
_get_admin_session had survived. It did not check what they call.

tests/test_admin_auth_wiring.py closes that gap: it exercises the routes rather
than the module. /admin/login with an unknown user must answer 401 rather than
500, a known user with a wrong password must reach the password check,
/admin/me and /admin/dashboard/overview must answer 401, /admin/logout must not
raise, and a direct assertion covers all five names.

Verified as a negative control: with the import removed again, all six fail.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@MoltyCel
MoltyCel merged commit bb230e4 into main Sep 4, 2026
14 checks passed
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.

1 participant