[FIX] ログインしてるユーザーはパスワード再設定後プロフィール画面に戻るように修正・パスワード再設定の際ハッシュ化処理
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import org.mindrot.jbcrypt.BCrypt;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.service.PasswordResetService;
|
||||
@@ -25,15 +26,16 @@ public class PasswordResetServiceImpl implements PasswordResetService {
|
||||
return false;
|
||||
}
|
||||
|
||||
UserEntity userEntity =
|
||||
userRepository.findById(userId).orElse(null);
|
||||
UserEntity userEntity = userRepository.findById(userId).orElse(null);
|
||||
|
||||
if (userEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String passwordHashed = BCrypt.hashpw(passwordResetForm.getPassword(), BCrypt.gensalt());
|
||||
|
||||
userEntity.setPassword(
|
||||
passwordResetForm.getPassword());
|
||||
passwordHashed);
|
||||
|
||||
userRepository.save(userEntity);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PasswordResetController {
|
||||
(LoginModel) session.getAttribute("loginUser");
|
||||
|
||||
if (loginUser != null) {
|
||||
return "redirect:/menu";
|
||||
return "redirect:/profile";
|
||||
}
|
||||
|
||||
return "redirect:/login";
|
||||
|
||||
Reference in New Issue
Block a user