[FIX] ログインしてるユーザーはパスワード再設定後プロフィール画面に戻るように修正・パスワード再設定の際ハッシュ化処理

This commit is contained in:
s-choi
2026-09-25 16:09:36 +09:00
parent cd4321ef8c
commit 2c445c1904
2 changed files with 22 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
package com.example.demo.app.domain.service.impl; package com.example.demo.app.domain.service.impl;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.example.demo.app.domain.service.PasswordResetService; import com.example.demo.app.domain.service.PasswordResetService;
@@ -25,15 +26,16 @@ public class PasswordResetServiceImpl implements PasswordResetService {
return false; return false;
} }
UserEntity userEntity = UserEntity userEntity = userRepository.findById(userId).orElse(null);
userRepository.findById(userId).orElse(null);
if (userEntity == null) { if (userEntity == null) {
return false; return false;
} }
String passwordHashed = BCrypt.hashpw(passwordResetForm.getPassword(), BCrypt.gensalt());
userEntity.setPassword( userEntity.setPassword(
passwordResetForm.getPassword()); passwordHashed);
userRepository.save(userEntity); userRepository.save(userEntity);

View File

@@ -62,7 +62,7 @@ public class PasswordResetController {
(LoginModel) session.getAttribute("loginUser"); (LoginModel) session.getAttribute("loginUser");
if (loginUser != null) { if (loginUser != null) {
return "redirect:/menu"; return "redirect:/profile";
} }
return "redirect:/login"; return "redirect:/login";