Laravel 8 清除令牌
如果你想清除被撤销或过期的令牌,Passport
会提供以下的命令来清除它:
# Purge revoked and expired tokens and auth codes...
php artisan passport:purge
# Only purge revoked tokens and auth codes...
php artisan passport:purge --revoked
# Only purge expired tokens and auth codes...
php artisan passport:purge --expired
你可以在控制台的 Kernel
类中配置任务调度(scheduled_job
)(/docs/laravel/8.x/scheduling) 来定时自动清理令牌:
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('passport:purge')->hourly();
}