1515import lombok .extern .slf4j .Slf4j ;
1616import org .springframework .beans .factory .annotation .Value ;
1717import org .springframework .scheduling .annotation .Scheduled ;
18+ import org .springframework .security .crypto .password .PasswordEncoder ;
1819import org .springframework .security .web .authentication .SimpleUrlAuthenticationSuccessHandler ;
1920import org .springframework .stereotype .Service ;
2021import org .springframework .transaction .annotation .Transactional ;
@@ -31,6 +32,7 @@ public class UserServiceImpl extends SimpleUrlAuthenticationSuccessHandler {
3132 private final UserRepository userRepository ;
3233 private final JwtUtilServiceImpl jwtUtilService ;
3334 private final RefreshTokenRepository refreshTokenRepository ;
35+ private final PasswordEncoder passwordEncoder ;
3436
3537 @ Value ("${jwt.access-token.expiration-time}" )
3638 private long ACCESS_TOKEN_EXPIRATION_TIME ; // 액세스 토큰 유효기간
@@ -59,7 +61,7 @@ public CommonDTO.IsSuccessDTO signUp(UserDTO.SingUpRequestDto request) {
5961
6062 User user = User .builder ()
6163 .email (request .getEmail ())
62- .password (request .getPassword ())
64+ .password (passwordEncoder . encode ( request .getPassword () ))
6365 .name (request .getName ())
6466 .userId (UUID .randomUUID ())
6567 .provider ("general" )
@@ -82,7 +84,7 @@ public CommonDTO.IsSuccessDTO login(UserDTO.LoginRequestDto request, HttpServlet
8284 User user = userRepository .findByEmail (request .getEmail ()).orElseThrow (()
8385 -> new UserHandler (ErrorStatus ._NOT_FOUND_USER ));
8486
85- if (!user . getPassword (). equals ( request .getPassword ()))
87+ if (!passwordEncoder . matches ( request . getPassword (), user .getPassword ()))
8688 throw new UserHandler (ErrorStatus ._NOT_CORRECT_PASSWORD );
8789
8890 refreshTokenRepository .deleteByUserId (user .getUserId ());
0 commit comments