1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-04-20 23:11:56 +02:00

Refactor the cron controller

This commit is contained in:
Kovah 2020-01-28 16:11:42 +01:00
parent c2949b5e5f
commit 559a068fd9
No known key found for this signature in database
GPG Key ID: AAAA031BA9830D7B
3 changed files with 5 additions and 5 deletions

View File

@ -12,17 +12,16 @@ class CronController extends Controller
{
/**
* @param Request $request
* @param null|string $cron_token
* @param string|null $cron_token
* @return ResponseFactory|Response
*/
public function run(Request $request, $cron_token)
public function __invoke(Request $request, $cron_token)
{
// Verify the cron token
if (!$cron_token || $cron_token !== systemsettings('cron_token')) {
abort(403);
return response(trans('settings.cron_token_auth_failure'), 403);
}
// Run all cron tasks
Artisan::call('schedule:run');
return response('Cron successfully executed');

View File

@ -63,4 +63,5 @@ return [
'cron_token_url' => 'Point your cron to the following URL: <span class="cron-token-url">:route</span>',
'cron_token_generate_info' => 'Caution: If you already have an cron token, generating a new one will break the existing cron job!',
'cron_token_generate_failure' => 'A new cron token could not be generated. Please check your browser console and application logs for more information.',
'cron_token_auth_failure' => 'The provided cron token is invalid',
];

View File

@ -74,7 +74,7 @@ Route::prefix('bookmarklet')->group(function () {
->name('bookmarklet-login');
});
Route::get('cron/{token}', [CronController::class, 'run'])->name('cron');
Route::get('cron/{token}', CronController::class)->name('cron');
// Model routes
Route::group(['middleware' => ['auth']], function () {