Auto-generate property codes and join by code
All checks were successful
build-and-deploy / build-deploy (push) Successful in 40s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 40s
This commit is contained in:
@@ -97,10 +97,12 @@ class PropertyAccessCodes(
|
||||
throw ResponseStatusException(HttpStatus.NOT_FOUND, "Invalid code")
|
||||
}
|
||||
val now = OffsetDateTime.now()
|
||||
val accessCode = accessCodeRepo.findActiveByPropertyAndCode(request.propertyId, code, now)
|
||||
val property = propertyRepo.findByCode(request.propertyCode.trim())
|
||||
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
|
||||
val accessCode = accessCodeRepo.findActiveByPropertyAndCode(property.id!!, code, now)
|
||||
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Invalid code")
|
||||
|
||||
val membershipId = PropertyUserId(propertyId = request.propertyId, userId = resolved.userId)
|
||||
val membershipId = PropertyUserId(propertyId = property.id, userId = resolved.userId)
|
||||
if (propertyUserRepo.existsById(membershipId)) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "User already a member")
|
||||
}
|
||||
@@ -111,7 +113,7 @@ class PropertyAccessCodes(
|
||||
|
||||
val propertyUser = PropertyUser(
|
||||
id = membershipId,
|
||||
property = accessCode.property,
|
||||
property = property,
|
||||
user = user,
|
||||
roles = accessCode.roles.toMutableSet()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user