I'm new to Spring Reactor, so i want to refactor this simply spring data (on kotlin) method:
fun save(user: User): Mono<User> {
if (findByEmail(user.email).block() != null) {
throw UserAlreadyExistsException()
}
user.password = passwordEncoder.encode(user.password)
return userRepository.save(user)
}
Thanks
(forgive me if the Kotlin syntax is wrong and if I'm doing things in Java style :o)
A shortened version without intermediary variables nor comments: