fix clean up expired code
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
const { generateEmailTransporter } = require("./mail");
|
const { generateEmailTransporter } = require("./mail");
|
||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
// Helper function to send email
|
// Helper function to send email
|
||||||
async function sendVerificationEmail(email, verificationCode) {
|
async function sendVerificationEmail(email, verificationCode) {
|
||||||
@@ -17,18 +18,17 @@ async function sendVerificationEmail(email, verificationCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean up expired verification codes (run this periodically)
|
// Clean up expired verification codes (run this periodically)
|
||||||
function cleanupExpiredCodes() {
|
const cleanupExpiredCodes = () => {
|
||||||
db_con.query(
|
db.execute(
|
||||||
"DELETE FROM AuthVerification WHERE Date < DATE_SUB(NOW(), INTERVAL 15 MINUTE) AND Authenticated = 0",
|
"DELETE FROM AuthVerification WHERE Date < DATE_SUB(NOW(), INTERVAL 15 MINUTE) AND Authenticated = 0"
|
||||||
(err, result) => {
|
)
|
||||||
if (err) {
|
.then((res) => {
|
||||||
console.error("Error cleaning up expired codes:", err);
|
console.log(`Cleaned up expired verification codes`);
|
||||||
} else {
|
})
|
||||||
console.log(`Cleaned up ${result} expired verification codes`);
|
.catch((err) => {
|
||||||
}
|
console.error("Error cleaning up expired codes:", err);
|
||||||
}
|
});
|
||||||
);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const checkDatabaseConnection = async (db) => {
|
const checkDatabaseConnection = async (db) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user