From 55215b2c362681927b82ec240686fec6e1d921df Mon Sep 17 00:00:00 2001 From: Leon Morival Date: Thu, 21 May 2026 21:47:46 +0200 Subject: [PATCH] feat: clean reset tokens daily --- routes/console.php | 8 ++++++++ tests/Feature/ScheduledAuthCleanupTest.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/Feature/ScheduledAuthCleanupTest.php diff --git a/routes/console.php b/routes/console.php index 0aeaeff..370ca60 100644 --- a/routes/console.php +++ b/routes/console.php @@ -9,6 +9,14 @@ Artisan::command('inspire', function () { })->purpose('Display an inspiring quote'); Schedule::command('horizon:snapshot')->everyFiveMinutes(); +Schedule::command('sanctum:prune-expired --hours=24') + ->daily() + ->withoutOverlapping() + ->onOneServer(); +Schedule::command('auth:clear-resets') + ->daily() + ->withoutOverlapping() + ->onOneServer(); Schedule::command('meal-posts:generate-ai') ->daily() ->withoutOverlapping(55) diff --git a/tests/Feature/ScheduledAuthCleanupTest.php b/tests/Feature/ScheduledAuthCleanupTest.php new file mode 100644 index 0000000..3b14cf9 --- /dev/null +++ b/tests/Feature/ScheduledAuthCleanupTest.php @@ -0,0 +1,16 @@ + true, + ]); + + $tasks = json_decode(Artisan::output(), true, flags: JSON_THROW_ON_ERROR); + $commands = collect($tasks)->pluck('command'); + + expect($commands) + ->toContain('php artisan sanctum:prune-expired --hours=24') + ->toContain('php artisan auth:clear-resets'); +});