From a030e9aaa093b03cb15f378eb94128fa6221d78d Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Wed, 28 Jan 2026 05:30:02 +0530 Subject: [PATCH] Allow public access for available room endpoints --- .../com/android/trisolarisserver/controller/Rooms.kt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/Rooms.kt b/src/main/kotlin/com/android/trisolarisserver/controller/Rooms.kt index c1c780e..bd7468b 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/Rooms.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/Rooms.kt @@ -132,9 +132,6 @@ class Rooms( @PathVariable propertyId: UUID, @AuthenticationPrincipal principal: MyPrincipal? ): List { - requirePrincipal(principal) - propertyAccess.requireMember(propertyId, principal!!.userId) - val rooms = roomRepo.findByPropertyIdOrderByRoomNumber(propertyId) val occupiedRoomIds = roomStayRepo.findOccupiedRoomIds(propertyId).toHashSet() return rooms @@ -150,17 +147,13 @@ class Rooms( @org.springframework.web.bind.annotation.RequestParam("availableOnly", required = false, defaultValue = "false") availableOnly: Boolean ): List { - requirePrincipal(principal) - propertyAccess.requireMember(propertyId, principal!!.userId) - val roomType = roomTypeRepo.findByPropertyIdAndCodeIgnoreCase(propertyId, roomTypeCode) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Room type not found") - val roles = propertyUserRepo.findRolesByPropertyAndUser(propertyId, principal.userId) val rooms = roomRepo.findByPropertyIdOrderByRoomNumber(propertyId) .filter { it.roomType.id == roomType.id } - if (availableOnly || isAgentOnly(roles)) { + if (availableOnly || (principal != null && isAgentOnly(propertyUserRepo.findRolesByPropertyAndUser(propertyId, principal.userId)))) { val occupiedRoomIds = roomStayRepo.findOccupiedRoomIds(propertyId).toHashSet() return rooms .filter { it.active && !it.maintenance && !occupiedRoomIds.contains(it.id) }