2026.06.04 frontend építés közben
This commit is contained in:
@@ -11,6 +11,7 @@ from app.db.session import get_db
|
||||
from app.core.security import decode_token, DEFAULT_RANK_MAP
|
||||
from app.models.identity import User, UserRole # JAVÍTVA: Új Identity modell használata
|
||||
from app.core.config import settings
|
||||
from app.core.translation_helper import t # Translation helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -46,8 +47,8 @@ async def get_current_token_payload(
|
||||
payload = decode_token(token)
|
||||
if not payload or payload.get("type") != "access":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Érvénytelen vagy lejárt munkamenet."
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail=t("AUTH.INVALID_OR_EXPIRED_SESSION")
|
||||
)
|
||||
return payload
|
||||
|
||||
@@ -62,7 +63,7 @@ async def get_current_user(
|
||||
if not user_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Token azonosítási hiba."
|
||||
detail=t("AUTH.TOKEN_IDENTIFICATION_ERROR")
|
||||
)
|
||||
|
||||
# JAVÍTVA: Modern SQLAlchemy 2.0 aszinkron lekérdezés with eager loading
|
||||
@@ -74,7 +75,7 @@ async def get_current_user(
|
||||
if not user or user.is_deleted:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="A felhasználó nem található."
|
||||
detail=t("AUTH.USER_NOT_FOUND")
|
||||
)
|
||||
return user
|
||||
|
||||
@@ -86,8 +87,8 @@ async def get_current_active_user(
|
||||
"""
|
||||
if not current_user.is_active:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="A művelethez aktív profil és KYC azonosítás szükséges."
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=t("AUTH.ACTIVE_PROFILE_KYC_REQUIRED")
|
||||
)
|
||||
return current_user
|
||||
|
||||
@@ -113,8 +114,8 @@ async def check_resource_access(
|
||||
return True
|
||||
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Nincs jogosultsága ehhez az erőforráshoz."
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=t("AUTH.NO_PERMISSION_FOR_RESOURCE")
|
||||
)
|
||||
|
||||
def check_min_rank(role_key: str):
|
||||
@@ -160,6 +161,6 @@ async def get_current_admin(
|
||||
if current_user.role not in allowed_roles:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Nincs megfelelő jogosultságod (Admin/Moderátor)!"
|
||||
detail=t("AUTH.INSUFFICIENT_ADMIN_PERMISSIONS")
|
||||
)
|
||||
return current_user
|
||||
Reference in New Issue
Block a user