fix(user): filter out soft-deleted memberships and organizations
Add get_active_memberships() method to User model that filters out soft-deleted memberships and memberships of deleted organizations. Update all usages of organization_memberships to use this method, ensuring consistent handling of soft-deleted records across the codebase. Also add deleted_at filters to CA queries in SSH helpers.
This commit is contained in:
@@ -329,7 +329,7 @@ def admin_hard_delete_user(user_id):
|
||||
if target.id == caller.id:
|
||||
return api_response(success=False, message="Cannot delete your own account via this endpoint.", status=400, error_type="BAD_REQUEST")
|
||||
|
||||
target_org_ids = {m.organization_id for m in target.organization_memberships}
|
||||
target_org_ids = {m.organization_id for m in target.get_active_memberships()}
|
||||
admin_in_shared_org = OrganizationMember.query.filter(
|
||||
OrganizationMember.user_id == caller.id,
|
||||
OrganizationMember.organization_id.in_(target_org_ids),
|
||||
|
||||
Reference in New Issue
Block a user