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

Починка админки

This commit is contained in:
MoonTestUse1
2024-12-31 02:46:52 +06:00
parent 4e12b51acb
commit 25a872beaf

View File

@@ -11,7 +11,6 @@ router = APIRouter()
async def login(credentials: dict, db: Session = Depends(get_db)):
"""Employee login endpoint"""
try:
# Validate required fields
if not credentials.get("lastName") or not credentials.get("password"):
raise HTTPException(
status_code=400,
@@ -36,4 +35,29 @@ async def login(credentials: dict, db: Session = Depends(get_db)):
raise
except Exception as e:
auth_logger.error(f"Login error: {e}", exc_info=True)
raise HTTPException(status_code=500, detail="Ошибка сервера")
@router.post("/admin")
async def admin_login(credentials: dict):
"""Admin login endpoint"""
try:
if not credentials.get("username") or not credentials.get("password"):
raise HTTPException(
status_code=400,
detail="Необходимо указать имя пользователя и пароль"
)
# Простая проверка для админа (в реальном приложении используйте безопасную аутентификацию)
if credentials["username"] == "admin" and credentials["password"] == "admin66":
return {"isAdmin": True}
raise HTTPException(
status_code=401,
detail="Неверные учетные данные администратора"
)
except HTTPException:
raise
except Exception as e:
auth_logger.error(f"Admin login error: {e}", exc_info=True)
raise HTTPException(status_code=500, detail="Ошибка сервера")