client frontend tested

This commit is contained in:
2025-05-21 16:50:46 +03:00
parent fdf9d2edb8
commit 82d16ed3c9
53 changed files with 2669 additions and 486 deletions

View File

@@ -20,7 +20,7 @@ from endpoints.index import endpoints_index
from api_validations.defaults.validations import CommonHeaders
from api_middlewares.token_provider import TokenProvider
from events.auth.events import LoginHandler
auth_route = APIRouter(prefix="/authentication", tags=["Authentication Cluster"])
@@ -124,8 +124,12 @@ auth_route_check_token = "AuthCheckToken"
)
def check_token(headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
"""Check if token is valid"""
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
return None
try:
if token_object := LoginHandler.authentication_check_token_valid(access_token=headers.token, domain=headers.domain):
return JSONResponse(status_code=status.HTTP_200_OK, content={"success": True})
except Exception as e:
print(e)
return JSONResponse(status_code=status.HTTP_401_UNAUTHORIZED, content={"success": False})
auth_route_refresh_token = "AuthRefreshToken"

View File

@@ -402,14 +402,7 @@ class LoginHandler:
def authentication_check_token_valid(cls, domain, access_token: str) -> bool:
redis_handler = RedisHandlers()
if auth_token := redis_handler.get_object_from_redis(access_token=access_token):
if auth_token.is_employee:
if domain not in auth_token.domain_list:
raise ValueError("EYS_00112")
return True
elif auth_token.is_occupant:
if domain not in auth_token.domain_list:
raise ValueError("EYS_00113")
return True
return True
return False