I'm trying to figure out how to log a Mono<String>
password with slf4j but it would always return a Monotype.
logger.info(login.getPassword()+" "+userRepository.findPasswordByUsername(login.getUsername()));
and
logger.info(login.getPassword()+" "+userRepository.findPasswordByUsername(login.getUsername()).toString());
the first 2 logging tries above
return the literal password
(from the request) and MonoNext
and ofc you cant use .block()
which just throws
"block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3"
yes i'm aware that i can pass a Subscriber / Consumer for onNext() like:
.subscribe(x -> System.out.println( x.toString()))
to get some output but how would i do that with a logger only, is there even a way ?
login
represents a user retrieved from a request.
The password is properly stored and encoded (Bycrypt) beforehand ofc (doesn't seem to be the issue).
Edit: to give more context
userRepository.findPasswordByUsername("username")
will return a Mono which i want to compare to another password as in:
passwordEncoder.matches( "userinputPW", userRepository.findPasswordByUsername("username") )
which is how you use a ByCryptEncoder in Spring and i can't .map()
the Mono to a String (will obviously always return an Object and not a String as explained here https://stackoverflow.com/a/47180610/6414816 )
Using spring-boot-starter-webflux, spring-boot-starter-data-r2dbc, spring-boot-starter-security
What am i missing ? Thanks in Advance.