alchemy flush and save functions updated
This commit is contained in:
@@ -50,15 +50,18 @@ def save_access_token_to_redis(
|
||||
Employees,
|
||||
Staff,
|
||||
)
|
||||
print('save_access_token_to_redis')
|
||||
if not found_user:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=dict(message="User is not found."),
|
||||
headers=request.headers,
|
||||
# headers=json.loads(json.dumps(request.headers)),
|
||||
)
|
||||
|
||||
print('save_access_token_to_redis', found_user)
|
||||
# Check user is already logged in or has a previous session
|
||||
already_tokens = get_object_via_user_uu_id(user_id=found_user.uu_id)
|
||||
print('already_tokens', already_tokens)
|
||||
for key in already_tokens or []:
|
||||
token_user = json.loads(redis_cli.get(key).decode() or {})
|
||||
if token_user.get("domain", "") == domain:
|
||||
@@ -67,11 +70,11 @@ def save_access_token_to_redis(
|
||||
access_token = (
|
||||
found_user.generate_access_token() if not access_token else access_token
|
||||
)
|
||||
|
||||
print('access_token', access_token)
|
||||
# Prepare the user's details to save in Redis Session
|
||||
if found_user.is_occupant: # Check if user is NOT an occupant
|
||||
living_spaces: list[BuildLivingSpace] = BuildLivingSpace.filter_active(
|
||||
BuildLivingSpace.person_id == found_user.person_id, filter_records=False
|
||||
living_spaces: list[BuildLivingSpace] = BuildLivingSpace.filter_all(
|
||||
BuildLivingSpace.person_id == found_user.person_id
|
||||
).data
|
||||
if not living_spaces:
|
||||
raise HTTPException(
|
||||
@@ -79,9 +82,9 @@ def save_access_token_to_redis(
|
||||
detail=dict(
|
||||
message="NO Living Space is found. This user has no proper account set please contact the admin."
|
||||
),
|
||||
headers=request.headers,
|
||||
# headers=json.loads(json.dumps(request.headers)),
|
||||
)
|
||||
|
||||
print('living_spaces', living_spaces)
|
||||
occupants_selection_dict = {}
|
||||
for living_space in living_spaces:
|
||||
build_parts_selection = BuildParts.filter_active(
|
||||
@@ -93,7 +96,7 @@ def save_access_token_to_redis(
|
||||
detail=dict(
|
||||
message="No build Part is found for the living space. Please contact the admin."
|
||||
),
|
||||
headers=request.headers,
|
||||
# headers=json.loads(json.dumps(request.headers)),
|
||||
)
|
||||
build_part = build_parts_selection.get(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user