[FIX] ログインの際、DBに保存されているパスワードが平文だったらハッシュ化して再保存するようにデモ用コードを追加しました。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user