- FastAPI app with lifespan, CORS, health endpoint - SQLAlchemy 2.0 async with aiosqlite, Base/UUIDMixin/TenantMixin/TimestampMixin - Tenant and User models with multi-tenant isolation - Auth: register (creates tenant+user), login, /me endpoint - JWT HS256 tokens, bcrypt password hashing - Alembic async setup with initial migration - 6 passing tests (register, login, wrong password, me, no token, health) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
14 lines
563 B
Python
14 lines
563 B
Python
from sqlalchemy import Boolean, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, UUIDMixin, TenantMixin, TimestampMixin
|
|
|
|
|
|
class User(Base, UUIDMixin, TenantMixin, TimestampMixin):
|
|
__tablename__ = "users"
|
|
email: Mapped[str] = mapped_column(String(200), unique=True, index=True)
|
|
password_hash: Mapped[str] = mapped_column(String(200))
|
|
nume: Mapped[str] = mapped_column(String(200))
|
|
rol: Mapped[str] = mapped_column(String(20), default="owner")
|
|
activ: Mapped[bool] = mapped_column(Boolean, default=True)
|