1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

add websockets suppor97

This commit is contained in:
MoonTestUse1
2025-01-05 02:58:54 +06:00
parent 563db1c7e6
commit 9a97764b78
3 changed files with 14 additions and 6 deletions

View File

@@ -3,11 +3,14 @@ from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from passlib.context import CryptContext
from sqlalchemy.orm import Session
import re
import logging
from .jwt import verify_token
from ..database import get_db
# Настраиваем логирование
logger = logging.getLogger(__name__)
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
security = HTTPBearer(auto_error=False)
@@ -46,6 +49,7 @@ def get_current_admin(
return {"is_admin": True}
except Exception as e:
logger.error(f"Authentication error: {e}")
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid authentication credentials",
@@ -78,7 +82,8 @@ def get_current_employee(
)
return {"id": employee_id}
except Exception:
except Exception as e:
logger.error(f"Authentication error: {e}")
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid authentication credentials",