Merge pull request #7342 from turbo124/master

Hosted Migration Filtering
This commit is contained in:
David Bomba 2022-03-30 10:55:08 +11:00 committed by GitHub
commit 38349476fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 5 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,8 +22,25 @@ class MigrationLookup
return $next($request);
}
if ($guard == 'user') {
//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/*')) {
return $next($request);
}
}
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),
];

View File

@ -123,7 +123,7 @@ if (Utils::isTravis()) {
Route::get('/check_data', 'AppController@checkData');
}
Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
Route::group(['middleware' => ['lookup:user', 'auth:user','migration_channel:user']], function () {
Route::get('logged_in', 'HomeController@loggedIn');
Route::get('dashboard', 'DashboardController@index');
Route::get('dashboard_chart_data/{group_by}/{start_date}/{end_date}/{currency_id}/{include_expenses}', 'DashboardController@chartData');