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:
@@ -1,6 +1,7 @@
|
||||
"""Application configuration"""
|
||||
from pydantic_settings import BaseSettings
|
||||
from typing import Optional
|
||||
from pydantic import ConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
@@ -32,9 +33,11 @@ class Settings(BaseSettings):
|
||||
if not self.DATABASE_URL:
|
||||
self.DATABASE_URL = f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
||||
|
||||
class Config:
|
||||
"""Pydantic config"""
|
||||
env_file = ".env"
|
||||
model_config = ConfigDict(
|
||||
env_file=".env",
|
||||
extra="allow", # Разрешаем дополнительные поля
|
||||
case_sensitive=True # Учитываем регистр
|
||||
)
|
||||
|
||||
|
||||
settings = Settings()
|
@@ -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",
|
||||
|
@@ -6,7 +6,7 @@ from fastapi import HTTPException, status
|
||||
from redis import Redis
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..core.config import settings
|
||||
from ..config import settings
|
||||
from ..models.token import Token
|
||||
from ..crud.employees import get_employee
|
||||
|
||||
|
Reference in New Issue
Block a user