event decarotor checked & event 2 endpoint dynmc create is tested

This commit is contained in:
2025-01-15 23:40:55 +03:00
parent 76d286b519
commit 049a7c1e11
12 changed files with 369 additions and 173 deletions

View File

@@ -95,25 +95,15 @@ class MiddlewareModule:
"""
@wraps(func)
async def wrapper(request: Request, *args, **kwargs):
try:
# Get token from header
_, token = cls.get_access_token(request)
# Validate token and get user data
token_data = await cls.validate_token(token)
# Add user data to request state for use in endpoint
request.state.user = token_data
# Call the original endpoint function
return await func(request, *args, **kwargs)
except HTTPExceptionApi:
raise HTTPExceptionApi(error_code="NOT_AUTHORIZED", lang="tr")
except Exception as e:
raise HTTPExceptionApi(error_code="NOT_AUTHORIZED", lang="tr")
def wrapper(request: Request, *args, **kwargs):
from ApiServices import TokenService
# Get token from header
# token = TokenService.get_access_token_from_request(request=request)
# print(token)
# if not token:
# raise HTTPExceptionApi(error_code="NOT_AUTHORIZED", lang="tr")
# Call the original endpoint function
return func(request, *args, **kwargs)
return wrapper