Files
service-finder/tests/archive/patch_auth_service.py.old

71 lines
3.0 KiB
Python

import re
with open('backend/app/services/auth_service.py', 'r') as f:
content = f.read()
shadow_logic = """
p = user.person
# --- SHADOW IDENTITY CHECK ---
shadow_stmt = select(Person).where(
and_(
Person.last_name == kyc_in.last_name if hasattr(kyc_in, "last_name") else Person.last_name == p.last_name,
Person.first_name == kyc_in.first_name if hasattr(kyc_in, "first_name") else Person.first_name == p.first_name,
Person.birth_date == kyc_in.birth_date,
Person.id != p.id # Ne a jelenlegit találja meg
)
)
if kyc_in.birth_date:
shadow_person = (await db.execute(shadow_stmt)).scalar_one_or_none()
else:
shadow_person = None
if shadow_person:
logger.info(f"Shadow Identity megtalálva a {user.id} userhez: Person ID {shadow_person.id}")
user.person_id = shadow_person.id
# Frissítjük a megtalált Person rekordot a KYC adatokkal
shadow_person.mothers_last_name = kyc_in.mothers_last_name
shadow_person.mothers_first_name = kyc_in.mothers_first_name
shadow_person.birth_place = kyc_in.birth_place
shadow_person.phone = kyc_in.phone_number
shadow_person.address_id = addr_id
shadow_person.identity_docs = jsonable_encoder(kyc_in.identity_docs)
shadow_person.is_active = True
# Inaktiváljuk/töröljük a megárvult eredeti Person-t
p.is_active = False
p.is_ghost = True
p = shadow_person
else:
p.mothers_last_name = kyc_in.mothers_last_name
p.mothers_first_name = kyc_in.mothers_first_name
p.birth_place = kyc_in.birth_place
p.birth_date = kyc_in.birth_date
p.phone = kyc_in.phone_number
p.address_id = addr_id
p.identity_docs = jsonable_encoder(kyc_in.identity_docs)
p.is_active = True
# --- SHADOW CHECK VÉGE ---
"""
old_logic = """ # Person adatok dúsítása
p = user.person
p.mothers_last_name = kyc_in.mothers_last_name
p.mothers_first_name = kyc_in.mothers_first_name
p.birth_place = kyc_in.birth_place
p.birth_date = kyc_in.birth_date
p.phone = kyc_in.phone_number
p.address_id = addr_id
p.identity_docs = jsonable_encoder(kyc_in.identity_docs)
p.is_active = True"""
if old_logic in content:
content = content.replace(old_logic, shadow_logic)
with open('backend/app/services/auth_service.py', 'w') as f:
f.write(content)
print("Patched auth_service.py")
else:
print("Could not find the target code in auth_service.py")