package dev.lions.unionflow.client.security;

import io.quarkus.scheduler.Scheduled;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.logging.Logger;

@ApplicationScoped
public class TokenCleanupService {
    
    private static final Logger LOGGER = Logger.getLogger(TokenCleanupService.class.getName());
    
    @Inject
    private TokenRefreshService tokenRefreshService;
    
    @Scheduled(every = "10m")
    public void cleanupExpiredTokens() {
        try {
            LOGGER.fine("Exécution du nettoyage des tokens expirés");
            tokenRefreshService.cleanupExpiredTokens();
            LOGGER.fine("Nettoyage des tokens terminé");
        } catch (Exception e) {
            LOGGER.warning("Erreur lors du nettoyage des tokens: " + e.getMessage());
        }
    }
}
