Add Banned role

This commit is contained in:
2026-01-14 22:13:07 +06:00
parent 011996d78d
commit 1eaba59f0f
7 changed files with 249 additions and 9 deletions

View File

@@ -123,7 +123,13 @@ def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(securit
if username not in users:
raise HTTPException(status_code=401, detail="Пользователь не найден")
return users[username]
user = users[username]
# Проверка на бан
if user.get("role") == "banned":
raise HTTPException(status_code=403, detail="Ваш аккаунт заблокирован")
return user
except JWTError:
raise HTTPException(status_code=401, detail="Неверный токен")
@@ -266,7 +272,7 @@ async def update_user_role(username: str, data: dict, user: dict = Depends(get_c
raise HTTPException(404, "Пользователь не найден")
new_role = data.get("role")
if new_role not in ["admin", "user", "support"]:
if new_role not in ["admin", "user", "support", "banned"]:
raise HTTPException(400, "Неверная роль")
users[username]["role"] = new_role

View File

@@ -11,7 +11,7 @@
"arkonsad": {
"username": "arkonsad",
"password": "$2b$12$z.AYkfa/MlTYFd9rLNfBmu9JHOFKUe8YdddnqCmRqAxc7vGQeo392",
"role": "user",
"role": "banned",
"servers": [
"123"
]