forgot password functionality

This commit is contained in:
2026-01-08 13:06:20 -06:00
parent dad65b81aa
commit 45f40c2f5d
4 changed files with 310 additions and 4 deletions

View File

@@ -256,6 +256,21 @@ const initializeAgenda = async (mongoUri, pool, io) => { // Now accepts pgPool
console.error("Error cleaning up users:", error);
}
});
// Define the password reset token deletion job
agenda.define('deletePasswordResetToken', async (job) => {
const { email } = job.attrs.data;
try {
const result = await pool.query('DELETE FROM password_reset_tokens WHERE email = $1', [email]);
if (result.rowCount > 0) {
console.log(`Deleted expired password reset token for ${email}`);
}
} catch (error) {
console.error(`Error deleting password reset token for ${email}:`, error);
}
});
await agenda.start();
agenda.on('ready', () => console.log('Agenda connected to MongoDB and ready!'));
agenda.on('start', (job) => console.log(`Job "${job.attrs.name}" starting`));