Refactor the upgrade pending check to see if there are settings/permissions yaml changes (#438)

This commit is contained in:
Nabeel S
2019-11-19 10:54:42 -05:00
committed by GitHub
parent 3ec64c989b
commit bffa5ebde2
5 changed files with 127 additions and 19 deletions

View File

@@ -1,25 +1,20 @@
<?php
/**
* Determine if an update is pending by checking if there are available migrations
* Redirect to the updater if there are. Done as middlware so it can happen before
* any authentication checks when someone goes to the admin panel
*/
namespace App\Http\Middleware;
use App\Services\Installer\MigrationService;
use App\Services\Installer\InstallerService;
use Closure;
/**
* Determine if an update is pending by checking in with the Installer service
*/
class UpdatePending
{
private $migrationSvc;
private $installerSvc;
/**
* @param MigrationService $migrationSvc
*/
public function __construct(MigrationService $migrationSvc)
public function __construct(InstallerService $installerSvc)
{
$this->migrationSvc = $migrationSvc;
$this->installerSvc = $installerSvc;
}
/**
@@ -30,7 +25,7 @@ class UpdatePending
*/
public function handle($request, Closure $next)
{
if (count($this->migrationSvc->migrationsAvailable()) > 0) {
if ($this->installerSvc->isUpgradePending()) {
return redirect('/update/step1');
}

View File

@@ -4,7 +4,7 @@
*/
Route::group([
'namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.',
'middleware' => ['update_pending', 'ability:admin,admin-access'],
'middleware' => ['ability:admin,admin-access'],
], static function () {
// CRUD for airlines
Route::resource('airlines', 'AirlinesController');
@@ -90,8 +90,8 @@ Route::group([
)->name('users.regen_apikey');
// defaults
Route::get('', ['uses' => 'DashboardController@index']);
Route::get('/', ['uses' => 'DashboardController@index']);
Route::get('', ['uses' => 'DashboardController@index'])->middleware('update_pending');
Route::get('/', ['uses' => 'DashboardController@index'])->middleware('update_pending');
Route::get('dashboard', ['uses' => 'DashboardController@index', 'name' => 'dashboard']);
Route::match(