Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
refactor SigninService.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Mar 20, 2024
1 parent 54dd6f5 commit e6ca973
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public Mono<TokenResponse> signin(LoginRequest request) {
return getUserPort.findByEmail(request.email())
.switchIfEmpty(Mono.error(UserNotFoundException.EXCEPTION))
.flatMap(user -> validateUserAndPassword(user, request.password()))
.flatMap(user -> tokenizer.createToken(user.getEmail())
.map(TokenResponse::create));
.flatMap(this::generateTokenResponse);
}

private Mono<TokenResponse> generateTokenResponse(User user) {
return tokenizer.createToken(user.getEmail())
.map(TokenResponse::create);
}

private Mono<User> validateUserAndPassword(User user, String inputPassword) {
Expand Down

0 comments on commit e6ca973

Please sign in to comment.