Skip to content

Commit

Permalink
Fix RestSourceUserService
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Oct 12, 2024
1 parent 207e6bb commit bcffef7
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ class RestSourceUserService(

suspend fun create(userDto: RestSourceUserDTO): RestSourceUserDTO {
userDto.ensure()
val existingUserDto = userMapper.fromEntity(
userRepository.findByUserIdProjectIdSourceType(
userId = userDto.userId!!,
projectId = userDto.projectId!!,
sourceType = userDto.sourceType,
)!!,
val existingUser = userRepository.findByUserIdProjectIdSourceType(
userId = userDto.userId!!,
projectId = userDto.projectId!!,
sourceType = userDto.sourceType,
)
if (existingUserDto != null) {
if (existingUser != null) {
val response = Response.status(Response.Status.CONFLICT)
.entity(mapOf("status" to 409, "message" to "User already exists.", "user" to existingUserDto))
.entity(mapOf("status" to 409, "message" to "User already exists.", "user" to userMapper.fromEntity(existingUser)))
.build()

throw WebApplicationException(response)
Expand Down

0 comments on commit bcffef7

Please sign in to comment.