[FIX] ログインしてるユーザーはパスワード再設定後プロフィール画面に戻るように修正・パスワード再設定の際ハッシュ化処理
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
Reference in New Issue
Block a user