
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)
19 lines
673 B
Python
19 lines
673 B
Python
from datetime import datetime
|
|
from sqlalchemy import Column, DateTime, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Role(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, unique=True, index=True, nullable=False)
|
|
description = Column(String, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
users = relationship("User", secondary="userrole", back_populates="roles")
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Role {self.name}>" |