7 Commits

Author SHA1 Message Date
estherdev03
15eddb8d13 Fix clearn up expired code 2025-04-20 22:14:04 -06:00
estherdev03
2e98a88db9 Merge branch 'esther2' of https://github.com/MannPatel0/Campus-Plug into esther2 2025-04-20 22:08:38 -06:00
Esther Tran
bcb912b6ce Merge pull request #5 from MannPatel0/main
merge
2025-04-20 22:08:03 -06:00
estherdev03
e83b3640a5 Merge branch 'esther2' of https://github.com/MannPatel0/Campus-Plug into esther2 2025-04-20 22:05:42 -06:00
estherdev03
bd69bed934 Merge branch 'main' of https://github.com/MannPatel0/Campus-Plug into esther2 2025-04-20 22:03:32 -06:00
estherdev03
51dffdae30 fix clean up expired code 2025-04-20 22:00:19 -06:00
Esther Tran
8dcaff3d6d Merge pull request #4 from MannPatel0/main
Merge pull request #3 from MannPatel0/esther2
2025-04-20 21:01:54 -06:00
2 changed files with 13 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ const pool = mysql.createPool({
host: "localhost", host: "localhost",
user: "root", user: "root",
database: "Marketplace", database: "Marketplace",
password: "12345678",
}); });
// const pool = mysql.createPool( // const pool = mysql.createPool(

View File

@@ -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.log(`Cleaned up expired verification codes`);
})
.catch((err) => {
console.error("Error cleaning up expired codes:", err); console.error("Error cleaning up expired codes:", err);
} else { });
console.log(`Cleaned up ${result} expired verification codes`); };
}
}
);
}
const checkDatabaseConnection = async (db) => { const checkDatabaseConnection = async (db) => {
try { try {