From 22eb28d138d12587c16c3734159ceeae9cca96e9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 10 Mar 2023 13:19:43 +1100 Subject: [PATCH] White label license --- app/Http/Controllers/LicenseController.php | 7 ++++--- lang/en/texts.php | 2 +- routes/api.php | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/LicenseController.php b/app/Http/Controllers/LicenseController.php index 72543ef1f1..7a70aa2cb9 100644 --- a/app/Http/Controllers/LicenseController.php +++ b/app/Http/Controllers/LicenseController.php @@ -149,14 +149,15 @@ class LicenseController extends BaseController return response()->json($error, 400); } - public function index(Request $request) + public function v5ClaimLicense(Request $request) { $this->checkLicense(); /* Catch claim license requests */ if (config('ninja.environment') == 'selfhost' && request()->has('license_key')) { - $response = Http::get( config('ninja.license_url')."/claim_license", [ + $response = Http::get( "http://ninja.test:8000/claim_license", [ + // $response = Http::get( "https://invoicing.co/claim_license", [ 'license_key' => $request->input('license_key'), 'product_id' => 3, ]); @@ -168,7 +169,7 @@ class LicenseController extends BaseController $account = auth()->user()->account; $account->plan_term = Account::PLAN_TERM_YEARLY; - $account->plan_expires = Carbon::parse($payload?->expires)->format('Y-m-d'); + $account->plan_expires = Carbon::parse($payload['expires'])->addYear()->format('Y-m-d'); $account->plan = Account::PLAN_WHITE_LABEL; $account->save(); diff --git a/lang/en/texts.php b/lang/en/texts.php index 33e29e69b5..20c7c4ee93 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2251,7 +2251,7 @@ $LANG = array( 'invalid_file' => 'Invalid file type', 'add_documents_to_invoice' => 'Add Documents to Invoice', 'mark_expense_paid' => 'Mark paid', - 'white_label_license_error' => 'Failed to validate the license, check storage/logs/laravel-error.log for more details.', + 'white_label_license_error' => 'Failed to validate the license, either expired or excessive activations. Email contact@invoiceninja.com for more information.', 'plan_price' => 'Plan Price', 'wrong_confirmation' => 'Incorrect confirmation code', 'oauth_taken' => 'The account is already registered', diff --git a/routes/api.php b/routes/api.php index 4d8342adfb..daf2db3a84 100644 --- a/routes/api.php +++ b/routes/api.php @@ -136,6 +136,7 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale'] Route::post('charts/chart_summary', [ChartController::class, 'chart_summary'])->name('chart.chart_summary'); Route::post('claim_license', [LicenseController::class, 'index'])->name('license.index'); + Route::post('v5_claim_license', [LicenseController::class, 'v5ClaimLicense'])->name('license.v5_claim_license'); Route::resource('clients', ClientController::class); // name = (clients. index / create / show / update / destroy / edit Route::put('clients/{client}/upload', [ClientController::class, 'upload'])->name('clients.upload');