4 ms·
fun register(registrationRequest: UserRegistrationRequest): UserDTO { return success(registrationRequest) .flatMap { validRequest ->
by Thorrez 11mo ago
fun register(registrationRequest: UserRegistrationRequest): UserDTO {
return success(registrationRequest)
.flatMap { validRequest ->
throwIfExists(validRequest.email) { authService.userExists(validRequest.email) }
}.flatMap {
runWithSafety { authService.register(registrationRequest.email, registrationRequest.password) }
}.getOrThrow()
}
There appears to be some useless code there. Why is validRequest.email being passed to throwIfExists twice? Why is throwIfExists implemented to return the email if the following line (runWithSafety) just ignores that returned email and instead gets the email from registrationRequest.email?
- jweir 11mo agoAnd won’t the authService.register function also error if the user already exists? Or will it allow double registering the account? There are deeper problems here that a Result type is not gonna fix.
- adammarples 11mo agoThe Authservice register function will error, it says so in the article