diff --git a/build.gradle b/build.gradle index e1b77c8..27c8ddc 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ dependencies { implementation 'org.springframework.data:spring-data-envers' implementation 'org.springframework.boot:spring-boot-starter-jdbc' - runtimeOnly 'org.springframework.boot:spring-boot-devtools' + developmentOnly 'org.springframework.boot:spring-boot-devtools' implementation 'org.springframework:spring-expression:5.3.30' implementation group: 'xalan', name: 'xalan', version: '2.7.3' diff --git a/src/main/java/com/eactive/apim/portal/apps/auth/service/AuthNumberStorage.java b/src/main/java/com/eactive/apim/portal/apps/auth/service/AuthNumberStorage.java index 85acad1..0e77bd5 100644 --- a/src/main/java/com/eactive/apim/portal/apps/auth/service/AuthNumberStorage.java +++ b/src/main/java/com/eactive/apim/portal/apps/auth/service/AuthNumberStorage.java @@ -18,18 +18,9 @@ public class AuthNumberStorage { } public void saveAuthNumber(String recipientKey, String authNumber, LocalDateTime expiresAt) { - - Optional exist = twoFactorAuthRepository.findByRecipient(recipientKey); - if (exist.isPresent()) { - TwoFactorAuth old = exist.get(); - old.setAuthNumber(authNumber); - old.setExpiresAt(expiresAt); - twoFactorAuthRepository.save(old); - } else { - TwoFactorAuth auth = new TwoFactorAuth(recipientKey, authNumber, expiresAt); - twoFactorAuthRepository.save(auth); - } - + twoFactorAuthRepository.deleteAllByRecipient(recipientKey); + TwoFactorAuth auth = new TwoFactorAuth(recipientKey, authNumber, expiresAt); + twoFactorAuthRepository.save(auth); } public Optional getAuthNumber(String recipientKey) {