recreate project
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Models\PasswordResetRequestModel;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class CleanupPasswordResets extends BaseCommand
|
||||
{
|
||||
protected $group = 'Maintenance';
|
||||
protected $name = 'cleanup:password-resets';
|
||||
protected $description = 'Delete password reset requests older than 30 days';
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
$model = new PasswordResetRequestModel();
|
||||
$threshold = Time::now()->subDays(30)->toDateTimeString();
|
||||
|
||||
$count = $model->where('requested_at <', $threshold)->delete();
|
||||
|
||||
CLI::write("Deleted $count old password reset request(s).", 'green');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Add this cron job to run every 24hrs
|
||||
0 0 * * * /usr/bin/php /path/to/project/public/index.php cleanup:password-resets >> /path/to/project/writable/logs/cleanup.log 2>&1
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user