-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthTokenCleanupScheduler.java
More file actions
30 lines (24 loc) · 1.1 KB
/
AuthTokenCleanupScheduler.java
File metadata and controls
30 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package learningFlow.learningFlow_BE.service.auth.common;
import learningFlow.learningFlow_BE.repository.EmailVerificationTokenRepository;
import learningFlow.learningFlow_BE.repository.PasswordResetTokenRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
@Component
@RequiredArgsConstructor
public class AuthTokenCleanupScheduler {
private final EmailVerificationTokenRepository emailVerificationTokenRepository;
private final PasswordResetTokenRepository tokenRepository;
@Scheduled(cron = "0 0 0 * * *") // 매일 자정에 실행
@Transactional
public void cleanupExpiredTokens() {
tokenRepository.deleteByExpiryDateBefore(LocalDateTime.now());
}
@Scheduled(cron = "0 0 0 * * *") // 매일 자정에 실행
@Transactional
public void cleanupExpiredEmailVerificationTokens() {
emailVerificationTokenRepository.deleteByExpiryDateBefore(LocalDateTime.now());
}
}