Add authentication log cleaning and associated tests

This commit is contained in:
Bubka
2024-05-24 13:50:19 +02:00
parent a9b1a20f30
commit e73fbf658f
5 changed files with 180 additions and 5 deletions

View File

@ -9,6 +9,7 @@ use App\Api\v1\Resources\UserManagerResource;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Password;
@ -215,6 +216,13 @@ class UserManagerController extends Controller
{
$this->authorize('view', $user);
// Here we purge the authentication log.
// Running the purge command when someone fetchs the auth log
// is not very elegant but it's straitforward compared
// to a scheduled task, and the delete query is light.
// => To enhance.
Artisan::call('2fauth:purge-log');
$validated = $this->validate($request, [
'period' => 'sometimes|numeric',
'limit' => 'sometimes|numeric',