Automated Action 5b55eedd2b Implement User Authentication and Authorization Service
This commit includes:
- User registration and authentication API with JWT
- Password reset functionality
- Role-based access control system
- Database models and migrations with SQLAlchemy and Alembic
- API documentation in README

generated with BackendIM... (backend.im)
2025-05-15 19:46:38 +00:00

14 lines
625 B
Python

from datetime import datetime
from sqlalchemy import Column, DateTime, ForeignKey, Integer, Table
from app.db.base_class import Base
# Association table for the many-to-many relationship between users and roles
class UserRole(Base):
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("user.id", ondelete="CASCADE"), nullable=False)
role_id = Column(Integer, ForeignKey("role.id", ondelete="CASCADE"), nullable=False)
created_at = Column(DateTime, default=datetime.utcnow)
def __repr__(self) -> str:
return f"<UserRole user_id={self.user_id} role_id={self.role_id}>"