event decarotor checked & event 2 endpoint dynmc create is tested
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user