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

Commit

Permalink
custom exception 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Feb 16, 2024
1 parent 1ffddf9 commit 44f5c8b
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.daemawiki.domain.user.dto.ChangePasswordRequest;
import com.example.daemawiki.domain.user.repository.UserRepository;
import com.example.daemawiki.domain.user.service.facade.UserFacade;
import com.example.daemawiki.global.exception.h401.PasswordMismatchException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
Expand All @@ -22,7 +23,7 @@ public ChangePassword(PasswordEncoder passwordEncoder, UserFacade userFacade, Us
public Mono<Void> execute(ChangePasswordRequest request) {
return userFacade.currentUser()
.filter(user -> passwordEncoder.matches(request.oldPassword(), user.getPassword()))
.switchIfEmpty(Mono.error(new RuntimeException()))
.switchIfEmpty(Mono.error(PasswordMismatchException.EXCEPTION))
.map(user -> {
user.changePassword(passwordEncoder.encode(request.newPassword()));
return user;
Expand Down

0 comments on commit 44f5c8b

Please sign in to comment.