Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Custom days and hours to passport purge command #1563

Merged
merged 3 commits into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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