Remove middleware [skip ci]

This commit is contained in:
James Cole 2018-05-13 09:58:21 +02:00
parent dc251c216c
commit 470b3e0973
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 11 additions and 10 deletions

View File

@ -168,22 +168,22 @@ class IndexController extends Controller
$isDemoUser = $this->userRepository->hasRole(auth()->user(), 'demo'); $isDemoUser = $this->userRepository->hasRole(auth()->user(), 'demo');
$isDebug = (bool)config('app.debug'); $isDebug = (bool)config('app.debug');
foreach ($providerNames as $providerName) { foreach ($providerNames as $providerName) {
Log::debug(sprintf('Now with provider %s', $providerName)); //Log::debug(sprintf('Now with provider %s', $providerName));
// only consider enabled providers // only consider enabled providers
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName)); $enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
$allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName)); $allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName));
$allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName)); $allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName));
if ($enabled === false) { if ($enabled === false) {
Log::debug('Provider is not enabled. NEXT!'); //Log::debug('Provider is not enabled. NEXT!');
continue; continue;
} }
if ($isDemoUser === true && $allowedForDemo === false) { if ($isDemoUser === true && $allowedForDemo === false) {
Log::debug('User is demo and this provider is not allowed for demo user. NEXT!'); //Log::debug('User is demo and this provider is not allowed for demo user. NEXT!');
continue; continue;
} }
if ($isDemoUser === false && $allowedForUser === false && $isDebug === false) { if ($isDemoUser === false && $allowedForUser === false && $isDebug === false) {
Log::debug('User is not demo and this provider is not allowed for such users. NEXT!'); //Log::debug('User is not demo and this provider is not allowed for such users. NEXT!');
continue; continue;
} }
@ -194,7 +194,7 @@ class IndexController extends Controller
$class = (string)config(sprintf('import.prerequisites.%s', $providerName)); $class = (string)config(sprintf('import.prerequisites.%s', $providerName));
$result = false; $result = false;
if ($class !== '' && class_exists($class)) { if ($class !== '' && class_exists($class)) {
Log::debug('Will not check prerequisites.'); //Log::debug('Will not check prerequisites.');
/** @var PrerequisitesInterface $object */ /** @var PrerequisitesInterface $object */
$object = app($class); $object = app($class);
$object->setUser(auth()->user()); $object->setUser(auth()->user());
@ -202,6 +202,7 @@ class IndexController extends Controller
} }
$providers[$providerName]['prereq_complete'] = $result; $providers[$providerName]['prereq_complete'] = $result;
} }
Log::debug(sprintf('Enabled providers: %s', json_encode(array_keys($providers))));
return $providers; return $providers;
} }

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Import\JobConfiguration\JobConfigurationInterface; use FireflyIII\Import\JobConfiguration\JobConfigurationInterface;
use FireflyIII\Models\ImportJob; use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
@ -57,7 +56,6 @@ class JobConfigurationController extends Controller
return $next($request); return $next($request);
} }
); );
$this->middleware(IsDemoUser::class);
} }
/** /**
@ -71,9 +69,11 @@ class JobConfigurationController extends Controller
*/ */
public function index(ImportJob $importJob) public function index(ImportJob $importJob)
{ {
Log::debug('Now in JobConfigurationController::index()');
// catch impossible status: // catch impossible status:
$allowed = ['has_prereq', 'need_job_config']; $allowed = ['has_prereq', 'need_job_config'];
if (null !== $importJob && !\in_array($importJob->status, $allowed, true)) { if (null !== $importJob && !\in_array($importJob->status, $allowed, true)) {
Log::debug(sprintf('Job has state "%s", but we only accept %s', $importJob->status, json_encode($allowed)));
session()->flash('error', trans('import.bad_job_status', ['status' => $importJob->status])); session()->flash('error', trans('import.bad_job_status', ['status' => $importJob->status]));
return redirect(route('import.index')); return redirect(route('import.index'));

View File

@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Import;
use Exception; use Exception;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Import\Routine\RoutineInterface; use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Import\Storage\ImportArrayStorage; use FireflyIII\Import\Storage\ImportArrayStorage;
use FireflyIII\Models\ImportJob; use FireflyIII\Models\ImportJob;
@ -57,7 +56,6 @@ class JobStatusController extends Controller
return $next($request); return $next($request);
} }
); );
$this->middleware(IsDemoUser::class);
} }
/** /**
@ -172,7 +170,9 @@ class JobStatusController extends Controller
if (null !== $importJob && !\in_array($importJob->status, $allowed, true)) { if (null !== $importJob && !\in_array($importJob->status, $allowed, true)) {
Log::error('Job is not ready.'); Log::error('Job is not ready.');
return response()->json(['status' => 'NOK', 'message' => sprintf('JobStatusController::start expects status "provider_finished" instead of "%s".', $importJob->status)]); return response()->json(
['status' => 'NOK', 'message' => sprintf('JobStatusController::start expects status "provider_finished" instead of "%s".', $importJob->status)]
);
} }
// set job to be storing data: // set job to be storing data: