feat(auth): make users.password_hash nullable for OAuth-only accounts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 03:24:07 -04:00
parent 143c979975
commit 453ba3fefc
3 changed files with 71 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
import pytest
from app.models.user import User
from app.models.account import Account
@pytest.mark.asyncio
async def test_user_can_be_created_without_password_hash(test_db):
"""OAuth-only users have password_hash=None and the row should commit cleanly."""
account = Account(name="OAuthShop", display_code="OAUTH001")
test_db.add(account)
await test_db.flush()
user = User(
email="oauth-only@example.com",
name="OAuth Only",
password_hash=None,
account_id=account.id,
account_role="engineer",
)
test_db.add(user)
await test_db.commit()
await test_db.refresh(user)
assert user.password_hash is None