[FIX] ログインの際、DBに保存されているパスワードが平文だったらハッシュ化して再保存するようにデモ用コードを追加しました。

This commit is contained in:
s-choi
2026-09-25 16:49:09 +09:00
parent 04a6b6dedb
commit 5be30572cb

View File

@@ -27,7 +27,22 @@ public class LoginServiceImpl implements LoginService {
return null;
}
boolean isValidPassword = BCrypt.checkpw(password, userEntity.getPassword());
boolean isValidPassword = false;
if (userEntity.getPassword().length() <= 24) {
if (userEntity.getPassword().equals(password)) {
userEntity.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
userRepository.save(userEntity);
isValidPassword = true;
} else {
return null;
}
} else {
isValidPassword = BCrypt.checkpw(password, userEntity.getPassword());
}
if (!isValidPassword) {
return null;