mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
cronjob thru url #1956
This commit is contained in:
parent
9720e66675
commit
e76c6265d7
@ -439,4 +439,29 @@ class AppController extends BaseController
|
||||
echo $invoice->getPDFString();
|
||||
exit;
|
||||
}
|
||||
|
||||
public function runCommand()
|
||||
{
|
||||
if (Utils::isNinjaProd()) {
|
||||
abort(400, 'Not allowed');
|
||||
}
|
||||
|
||||
$command = request()->command;
|
||||
$options = request()->options ?: [];
|
||||
$secret = env('CRON_SECRET');
|
||||
|
||||
if (! $secret) {
|
||||
exit('Set a value for CRON_SECRET in the .env file');
|
||||
} elseif (! hash_equals($secret, request()->secret ?: '')) {
|
||||
exit('Invalid secret');
|
||||
}
|
||||
|
||||
if (! $command || ! in_array($command, ['send-invoices', 'send-reminders', 'update-key'])) {
|
||||
exit('Invalid command: Valid options are send-invoices, send-reminders or update-key');
|
||||
}
|
||||
|
||||
Artisan::call('ninja:' . $command, $options);
|
||||
|
||||
return response(nl2br(Artisan::output()));
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,10 @@ Route::group(['middleware' => ['lookup:contact']], function () {
|
||||
Route::get('/proposal/image/{account_key}/{document_key}/{filename?}', 'ClientPortalProposalController@getProposalImage');
|
||||
});
|
||||
|
||||
if (Utils::isSelfHost()) {
|
||||
Route::get('/run_command', 'AppController@runCommand');
|
||||
}
|
||||
|
||||
if (Utils::isReseller()) {
|
||||
Route::post('/reseller_stats', 'AppController@stats');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user