From 44f5c8b2afb6cd568a7430b218bf5142f611cdc0 Mon Sep 17 00:00:00 2001 From: 101 Date: Fri, 16 Feb 2024 10:39:37 +0900 Subject: [PATCH] =?UTF-8?q?custom=20exception=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/daemawiki/domain/user/service/ChangePassword.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/daemawiki/domain/user/service/ChangePassword.java b/src/main/java/com/example/daemawiki/domain/user/service/ChangePassword.java index 93260a62..0e2e6f64 100644 --- a/src/main/java/com/example/daemawiki/domain/user/service/ChangePassword.java +++ b/src/main/java/com/example/daemawiki/domain/user/service/ChangePassword.java @@ -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; @@ -22,7 +23,7 @@ public ChangePassword(PasswordEncoder passwordEncoder, UserFacade userFacade, Us public Mono 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;