Skip to content
Snippets Groups Projects
Unverified Commit e6cbc318 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #4451 from JediKev/issue/clean-expired-pwresets

cron: Clean Expired Passwd Resets
parents 23b8995b 70b37d47
No related branches found
No related tags found
No related merge requests found
......@@ -176,6 +176,20 @@ extends VerySimpleModel {
$this->updated = SqlFunction::NOW();
return parent::save($this->dirty || $refetch);
}
// Clean password reset tokens that have expired
static function cleanPwResets() {
global $cfg;
if (!$cfg || !($period = $cfg->getPwResetWindow())) // In seconds
return false;
return ConfigItem::objects()
->filter(array(
'namespace' => 'pwreset',
'updated__lt' => SqlFunction::NOW()->minus(SqlInterval::SECOND($period)),
))->delete();
}
}
class OsticketConfig extends Config {
......
......@@ -56,6 +56,11 @@ class Cron {
DbSessionBackend::cleanup();
}
function CleanPwResets() {
require_once(INCLUDE_DIR.'class.config.php');
ConfigItem::cleanPwResets();
}
function MaybeOptimizeTables() {
// Once a week on a 5-minute cron
$chance = rand(1,2000);
......@@ -106,6 +111,7 @@ class Cron {
self::TicketMonitor();
self::PurgeLogs();
self::CleanExpiredSessions();
self::CleanPwResets();
// Run file purging about every 10 cron runs
if (mt_rand(1, 9) == 4)
self::CleanOrphanedFiles();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment