1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-18 23:42:25 +02:00

Hosted Migration Filtering

This commit is contained in:
David Bomba 2022-03-30 10:54:20 +11:00
parent 76c4cc982f
commit 76631a7f59
5 changed files with 23 additions and 7 deletions

View File

@ -99,6 +99,7 @@ class ExportMigrations extends Command
private function export($user)
{
$this->account = $user->account;
Auth::login($user);
$date = date('Y-m-d');
$accountKey = $this->account->account_key;

View File

@ -345,7 +345,12 @@ class AppController extends BaseController
FROM information_schema.TABLES
WHERE TABLE_NAME='clients' AND TABLE_SCHEMA='ninja'");
if (count($result) && $result[0]->engine == 'InnoDB') {
if(property_exists($result[0], 'engine'))
$engine = $result[0]->engine;
else
$engine = $result[0]->ENGINE;
if (count($result) && $engine == 'InnoDB') {
return;
}

View File

@ -11,6 +11,7 @@ use App\Models\LookupProposalInvitation;
use App\Models\LookupAccountToken;
use App\Models\LookupUser;
use Auth;
use Illuminate\Support\Carbon;
use Utils;
class MigrationLookup
@ -21,9 +22,11 @@ class MigrationLookup
return $next($request);
}
//need to wrap an additional block over this to funnel users in a particular range
//need to wrap an additional block over this to funnel users in a particular range
if(auth()->user()->id >= config('ninja.migration_user_start') &&
auth()->user()->id <= config('ninja.migration_user_end') &&
(!auth()->user()->account->company->plan_expires || Carbon::parse(auth()->user()->account->company->plan_expires)->lt(now())))
{
if ($guard == 'user') {
if(request()->is('migration/*') || request()->is('settings/*')) {
@ -32,10 +35,14 @@ class MigrationLookup
}
}
return redirect('/settings/account_management');
return redirect('/settings/account_management')->with('warning','V4 is now disabled for your account. Please migrate.');
}
elseif(!auth()->user()->account->company->plan_expires || Carbon::parse(auth()->user()->account->company->plan_expires)->lt(now())){
session()->flash('warning','Please consider migrating to V5, V4 has entered end of life.');
}
return $next($request);
}
}

View File

@ -165,7 +165,7 @@ class HostedMigration extends Job
$localMigrationData['force'] = array_key_exists('force', $company);
Storage::makeDirectory('migrations');
$file = Storage::path("migrations/{$fileName}.zip");
$file = Storage::path("app/migrations/{$fileName}.zip");
//$file = storage_path("migrations/{$fileName}.zip");

View File

@ -48,5 +48,8 @@ return [
],
'ninja_hosted_secret' => env('NINJA_HOSTED_SECRET', false),
'migration_db' => env('MIGRATION_DB', DB_NINJA_1),
'migration_user_start' => env('MIGRATION_USER_START', 1),
'migration_user_end' => env('MIGRATION_USER_END', 1000),
];