
- Create User model and schema - Implement password hashing with bcrypt - Add JWT token-based authentication - Create user and auth endpoints - Update todo endpoints with user authentication - Add alembic migration for user model - Update README with new features
20 lines
738 B
Python
20 lines
738 B
Python
from sqlalchemy import Boolean, Column, Integer, String, DateTime
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.database import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True)
|
|
username = Column(String, unique=True, index=True)
|
|
hashed_password = Column(String)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# Relationship with Todo items
|
|
todos = relationship("Todo", back_populates="owner", cascade="all, delete-orphan") |