1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00

Check white label license periodically

This commit is contained in:
David Bomba 2021-04-20 22:45:35 +10:00
parent 68ddc6e7b1
commit b33df0746e
2 changed files with 24 additions and 0 deletions

View File

@ -81,6 +81,7 @@ class LicenseController extends BaseController
*/
public function index()
{
$this->checkLicense();
/* Catch claim license requests */
if (config('ninja.environment') == 'selfhost' && request()->has('license_key')) {
@ -140,4 +141,15 @@ class LicenseController extends BaseController
return response()->json($error, 400);
}
private function checkLicense()
{
$account = auth()->user()->company()->account;
if($account->plan == 'white_label' && $account->plan_expires->lt(now())){
$account->plan = null;
$account->plan_expires = null;
$account->save();
}
}
}

View File

@ -12,6 +12,7 @@
namespace App\Jobs\Util;
use App\Models\Account;
use App\Utils\Ninja;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@ -40,5 +41,16 @@ class VersionCheck implements ShouldQueue
if ($version_file) {
Account::whereNotNull('id')->update(['latest_version' => $version_file]);
}
if(Ninja::isSelfHost())
{
$account = Account::first();
if($account->plan == 'white_label' && $account->plan_expires->lt(now())){
$account->plan = null;
$account->plan_expires = null;
$account->save();
}
}
}
}