Skip to content

Commit

Permalink
[11.x] Custom days and hours to passport purge command (#1563)
Browse files Browse the repository at this point in the history
* Custom days and hours to passport purge command

* lint fix

* formatting

Co-authored-by: Ruben Garcia <ruben.garcia@personio.de>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
3 people committed Aug 24, 2022
1 parent dac2be6 commit 5629f1a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Console/PurgeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class PurgeCommand extends Command
*/
protected $signature = 'passport:purge
{--revoked : Only purge revoked tokens and authentication codes}
{--expired : Only purge expired tokens and authentication codes}';
{--expired : Only purge expired tokens and authentication codes}
{--hours= : The number of hours to retain expired tokens}';

/**
* The console command description.
Expand All @@ -29,7 +30,9 @@ class PurgeCommand extends Command
*/
public function handle()
{
$expired = Carbon::now()->subDays(7);
$expired = $this->option('hours')
? Carbon::now()->subHours($this->option('hours'))
: Carbon::now()->subDays(7);

if (($this->option('revoked') && $this->option('expired')) ||
(! $this->option('revoked') && ! $this->option('expired'))) {
Expand Down

0 comments on commit 5629f1a

Please sign in to comment.