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

Fix tests

This commit is contained in:
MoonTestUse1
2025-01-06 23:40:39 +06:00
parent 161361609d
commit fec52c777b
17 changed files with 249 additions and 368 deletions

View File

@@ -42,16 +42,17 @@ async def admin_login(
db: Session = Depends(get_db)
):
"""Авторизация администратора"""
if form_data.username != "admin" or form_data.password != "admin123":
# Проверяем учетные данные администратора
employee = employees.get_employee_by_last_name(db, form_data.username)
if not employee or not employee.is_admin or not verify_password(form_data.password, employee.hashed_password):
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Incorrect username or password",
headers={"WWW-Authenticate": "Bearer"},
)
# Для админа используем специальный ID
admin_id = -1
access_token = create_and_save_token(admin_id, db)
# Создаем и сохраняем токен
access_token = create_and_save_token(employee.id, db)
return {
"access_token": access_token,