refactor(auth): Use user_id as JWT sub and implement get_user_by_id

Switched from username to user_id as the primary identifier in JWT tokens to better support external authentication providers. Added get_user_by_id to HistoryManager and updated API dependencies and tests to reflect these changes.
This commit is contained in:
Yunxiao Xu
2026-02-11 16:41:27 -08:00
parent ceddacf9cb
commit b23fbce8d0
9 changed files with 31 additions and 15 deletions

View File

@@ -17,7 +17,7 @@ def mock_user():
@pytest.fixture
def auth_header(mock_user):
app.dependency_overrides[get_current_user] = lambda: mock_user
token = create_access_token(data={"sub": mock_user.username, "user_id": mock_user.id})
token = create_access_token(data={"sub": mock_user.id})
yield {"Authorization": f"Bearer {token}"}
app.dependency_overrides.clear()