jogosultsági szintek RBAC beállítva tesztelve

This commit is contained in:
Roo
2026-06-25 20:41:49 +00:00
parent 52011606ff
commit 36109fc722
242 changed files with 8672 additions and 2237 deletions

View File

@@ -20,6 +20,7 @@ if TYPE_CHECKING:
from .payment import PaymentIntent, WithdrawalRequest
from .social import ServiceReview, SocialAccount
from ..marketplace.service_request import ServiceRequest
from ..system.rbac import SystemRole
class UserRole(str, enum.Enum):
"""Rendszerszintű (System-level) szerepkörök.
@@ -132,6 +133,15 @@ class User(Base):
email: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
hashed_password: Mapped[Optional[str]] = mapped_column(String)
# RBAC Phase 1: DB-driven role FK (nullable initially for migration safety)
role_id: Mapped[Optional[int]] = mapped_column(
Integer,
ForeignKey("system.roles.id", ondelete="SET NULL"),
nullable=True,
index=True
)
# Legacy: Keep UserRole enum column for backward compatibility during migration
role: Mapped[UserRole] = mapped_column(
PG_ENUM(UserRole, name="userrole", schema="identity"),
default=UserRole.USER
@@ -188,10 +198,17 @@ class User(Base):
# --- KAPCSOLATOK ---
# RBAC Phase 1: DB-driven role relationship
system_role: Mapped[Optional["SystemRole"]] = relationship(
"SystemRole",
foreign_keys=[role_id],
lazy="joined"
)
# JAVÍTÁS 4: Itt is explicit megadjuk, hogy melyik kulcs köti az emberhez
person: Mapped[Optional["Person"]] = relationship(
"Person",
foreign_keys=[person_id],
"Person",
foreign_keys=[person_id],
back_populates="users"
)