diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index c136a8a..8b018c3 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -406,14 +406,17 @@ class FalukantService extends BaseService { ] }, ], - attributes: ['money', 'creditAmount', 'todayCreditTaken',] + attributes: ['id', 'money', 'creditAmount', 'todayCreditTaken'] }); if (!u) throw new Error('User not found'); // Load UserHouse and HouseType in separate queries to avoid EagerLoadingError - const userHouse = await UserHouse.findOne({ - where: { userId: u.id }, - attributes: ['roofCondition', 'houseTypeId'] - }); + let userHouse = null; + if (u.id != null) { + userHouse = await UserHouse.findOne({ + where: { userId: u.id }, + attributes: ['roofCondition', 'houseTypeId'] + }); + } if (userHouse?.houseTypeId) { const houseType = await HouseType.findOne({ where: { id: userHouse.houseTypeId },