- Create User model with bcrypt password hashing - Add auth routes: register, login, refresh, me - Implement JWT access and refresh tokens - Add get_current_user dependency for protected routes - Update Task model with user_id foreign key for data isolation - Update TaskService to filter tasks by authenticated user - Add auth configuration (secret key, token expiry)
19 lines
587 B
Python
19 lines
587 B
Python
import uuid
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, String, DateTime
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from ..db import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
email = Column(String, unique=True, nullable=False, index=True)
|
|
password_hash = Column(String, nullable=False)
|
|
name = Column(String, nullable=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
|
|
tasks = relationship("Task", back_populates="owner", cascade="all, delete-orphan")
|