refactor: translate all docstrings and comments to English (STRICT ENGLISH POLICY complete)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""
|
||||
[C-01] JWT Authentication Module
|
||||
Implementare Bearer token authentication pentru API endpoints.
|
||||
Implement Bearer token authentication for API endpoints.
|
||||
"""
|
||||
import os
|
||||
from datetime import datetime, timedelta, timezone
|
||||
@@ -13,7 +13,7 @@ from pydantic import BaseModel
|
||||
# Configuration
|
||||
SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
|
||||
if not SECRET_KEY:
|
||||
# Genereaza o cheie de fallback pentru dev (NU PENTRU PRODUCȚIE)
|
||||
# Generate fallback key for dev (NOT FOR PRODUCTION)
|
||||
import secrets
|
||||
SECRET_KEY = secrets.token_urlsafe(32)
|
||||
import sys
|
||||
@@ -60,8 +60,8 @@ def create_access_token(user_id: int, username: str, role: str, expires_delta: O
|
||||
|
||||
async def get_current_user(credentials: HTTPAuthCredentials = Depends(security)):
|
||||
"""
|
||||
Dependency que valideaza JWT token din Authorization header.
|
||||
Returneaza TokenData cu user_id, username, role.
|
||||
Dependency that validates JWT token from Authorization header.
|
||||
Returns TokenData with user_id, username, role.
|
||||
"""
|
||||
token = credentials.credentials
|
||||
try:
|
||||
@@ -91,7 +91,7 @@ async def get_current_user(credentials: HTTPAuthCredentials = Depends(security))
|
||||
|
||||
|
||||
async def get_current_admin(current_user: TokenData = Depends(get_current_user)):
|
||||
"""Dependency que verifica daca user-ul are rol 'admin'."""
|
||||
"""Dependency that checks if user has 'admin' role."""
|
||||
if current_user.role != "admin":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
|
||||
Reference in New Issue
Block a user