aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/EmailServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service/EmailServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/EmailServiceImpl.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/EmailServiceImpl.java b/src/main/java/com/juick/service/EmailServiceImpl.java
index 977d9a75..7f358533 100644
--- a/src/main/java/com/juick/service/EmailServiceImpl.java
+++ b/src/main/java/com/juick/service/EmailServiceImpl.java
@@ -24,6 +24,10 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
+import java.sql.Types;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
import java.util.List;
/**
@@ -110,4 +114,11 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService {
getJdbcTemplate().update("DELETE FROM auth WHERE authcode=?", code);
}
+ @Override
+ public Integer cleanupAuthCodes() {
+ Instant day = Instant.now().minus(1, ChronoUnit.DAYS);
+ return getNamedParameterJdbcTemplate().update("DELETE FROM auth WHERE ts < :day",
+ new MapSqlParameterSource()
+ .addValue("day", day.atOffset(ZoneOffset.UTC), Types.TIMESTAMP_WITH_TIMEZONE));
+ }
}