sqlalchemy updated
This commit is contained in:
@@ -88,8 +88,15 @@ class AuthenticationLoginEventMethods(MethodToEvent):
|
||||
|
||||
# Return response with token and headers
|
||||
return {
|
||||
**token,
|
||||
"headers": dict(request.headers),
|
||||
"completed": True,
|
||||
"message": "User is logged in successfully",
|
||||
"access_token": token.get("access_token"),
|
||||
"refresh_token": token.get("refresher_token"),
|
||||
"access_object": {
|
||||
"user_type": token.get("user_type"),
|
||||
"companies_list": token.get("companies_list"),
|
||||
},
|
||||
"user": token.get("user"),
|
||||
}
|
||||
|
||||
|
||||
@@ -176,6 +183,9 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||
|
||||
# Get reachable events
|
||||
reachable_event_codes = Event2Employee.get_event_codes(employee_id=employee.id)
|
||||
reachable_event_endpoints = Event2Employee.get_event_endpoints(
|
||||
employee_id=employee.id
|
||||
)
|
||||
|
||||
# Get staff and duties
|
||||
staff = Staff.filter_one(Staff.id == employee.staff_id, db=db_session).data
|
||||
@@ -206,6 +216,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||
employee_id=employee.id,
|
||||
employee_uu_id=employee.uu_id.__str__(),
|
||||
reachable_event_codes=reachable_event_codes,
|
||||
reachable_event_endpoints=reachable_event_endpoints,
|
||||
)
|
||||
try: # Update Redis
|
||||
update_token = TokenService.update_token_at_redis(
|
||||
@@ -246,6 +257,10 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||
reachable_event_codes = Event2Occupant.get_event_codes(
|
||||
build_living_space_id=selected_build_living_space.id
|
||||
)
|
||||
reachable_event_endpoints = Event2Occupant.get_event_endpoints(
|
||||
build_living_space_id=selected_build_living_space.id
|
||||
)
|
||||
|
||||
occupant_type = OccupantTypes.filter_one(
|
||||
OccupantTypes.id == selected_build_living_space.occupant_type_id,
|
||||
db=db,
|
||||
@@ -289,6 +304,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||
responsible_company_id=company_related.id,
|
||||
responsible_company_uuid=company_related.uu_id.__str__(),
|
||||
reachable_event_codes=reachable_event_codes,
|
||||
reachable_event_endpoints=reachable_event_endpoints,
|
||||
)
|
||||
|
||||
try: # Update Redis
|
||||
|
||||
@@ -69,9 +69,10 @@ async def authentication_select_company_or_occupant_type(
|
||||
request=request, data=data, token_dict=auth_dict
|
||||
):
|
||||
if data.is_employee:
|
||||
return {"selected_company": data.company_uu_id}
|
||||
return {"selected_company": data.company_uu_id, "completed": True}
|
||||
elif data.is_occupant:
|
||||
return {"selected_occupant": data.build_living_space_uu_id}
|
||||
return {"selected_occupant": data.build_living_space_uu_id, "completed": True}
|
||||
return {"completed": False, "selected_company": None, "selected_occupant": None}
|
||||
|
||||
|
||||
@endpoint_wrapper("/authentication/login")
|
||||
@@ -87,10 +88,9 @@ async def authentication_login_with_domain_and_creds(
|
||||
)
|
||||
|
||||
|
||||
@endpoint_wrapper("/authentication/check")
|
||||
@endpoint_wrapper("/authentication/valid")
|
||||
async def authentication_check_token_is_valid(
|
||||
request: "Request",
|
||||
data: EndpointBaseRequestModel,
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Check if a token is valid.
|
||||
@@ -99,12 +99,10 @@ async def authentication_check_token_is_valid(
|
||||
access_token = TokenService.get_access_token_from_request(request=request)
|
||||
if TokenService.get_object_via_access_key(access_token=access_token):
|
||||
return {
|
||||
"status": True,
|
||||
"message": "Access Token is valid",
|
||||
}
|
||||
except HTTPException:
|
||||
return {
|
||||
"status": False,
|
||||
"message": "Access Token is NOT valid",
|
||||
}
|
||||
|
||||
@@ -261,9 +259,9 @@ AUTH_CONFIG = RouteFactoryConfig(
|
||||
),
|
||||
EndpointFactoryConfig(
|
||||
url_prefix=prefix,
|
||||
url_endpoint="/check",
|
||||
url_of_endpoint="/authentication/check",
|
||||
endpoint="/check",
|
||||
url_endpoint="/valid",
|
||||
url_of_endpoint="/authentication/valid",
|
||||
endpoint="/valid",
|
||||
method="GET",
|
||||
summary="Check access token is valid",
|
||||
description="Check access token is valid",
|
||||
|
||||
Reference in New Issue
Block a user