Skip to content

Commit b663762

Browse files
committed
Delete associated hiker profiles when a user account is deleted
- Added functionality to remove HikerProfile entries linked to the user during account deletion. - Ensured that all related data is cleaned up to maintain database integrity.
1 parent f93f3e6 commit b663762

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

app/api/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Item, Category, ItemCategory, Kit, KitItem, Pack, PackItem,
2222
Post, Trip, Image, TripCondition, TripGeography,
2323
Comment, Follow, LikePost, LikeTrip, LikeComment, LikeImage, Reported,
24+
HikerProfile,
2425
)
2526
from utils.auth import authenticate, generate_jwt, set_auth_cookie
2627
from cryptography.hazmat.primitives import serialization
@@ -594,6 +595,9 @@ def delete_account(response: Response, user: User = Depends(authenticate)):
594595
db.session.query(ItemCategory).filter_by(user_id=user_id).delete(synchronize_session=False)
595596
db.session.query(Category).filter_by(user_id=user_id).delete(synchronize_session=False)
596597

598+
# Hiker profiles
599+
db.session.query(HikerProfile).filter_by(user_id=user_id).delete(synchronize_session=False)
600+
597601
# Auth artifacts
598602
db.session.query(EmailVerification).filter_by(user_id=user_id).delete(synchronize_session=False)
599603
db.session.query(AuthOtp).filter(AuthOtp.email == email).delete(synchronize_session=False)

0 commit comments

Comments
 (0)