Add middleware and refactor admin handlers for improved functionality
- Introduced `DependenciesMiddleware` and `BlacklistMiddleware` for enhanced request handling across all routers. - Refactored admin handlers to utilize new middleware, improving access control and error handling. - Updated the `admin_router` to include middleware for access checks and streamlined the process of banning users. - Enhanced the structure of admin handler imports for better organization and maintainability. - Improved error handling in various admin functions to ensure robust user interactions.
This commit is contained in:
23
helper_bot/handlers/admin/exceptions.py
Normal file
23
helper_bot/handlers/admin/exceptions.py
Normal file
@@ -0,0 +1,23 @@
|
||||
class AdminError(Exception):
|
||||
"""Базовое исключение для административных операций"""
|
||||
pass
|
||||
|
||||
|
||||
class AdminAccessDeniedError(AdminError):
|
||||
"""Исключение при отказе в административном доступе"""
|
||||
pass
|
||||
|
||||
|
||||
class UserNotFoundError(AdminError):
|
||||
"""Исключение при отсутствии пользователя"""
|
||||
pass
|
||||
|
||||
|
||||
class InvalidInputError(AdminError):
|
||||
"""Исключение при некорректном вводе данных"""
|
||||
pass
|
||||
|
||||
|
||||
class UserAlreadyBannedError(AdminError):
|
||||
"""Исключение при попытке забанить уже заблокированного пользователя"""
|
||||
pass
|
||||
Reference in New Issue
Block a user