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?

And 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.

The Authservice register function will error, it says so in the article