Some code fixes.

This commit is contained in:
James Cole 2016-09-17 09:50:40 +02:00
parent 6e33e26ddf
commit 5ca9099654
9 changed files with 29 additions and 15 deletions

View File

@ -18,7 +18,7 @@ use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Illuminate\Validation\ValidationException as ValException;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
@ -40,7 +40,7 @@ class Handler extends ExceptionHandler
HttpException::class,
ModelNotFoundException::class,
TokenMismatchException::class,
ValidationException::class,
ValException::class,
];
/**

View File

@ -59,7 +59,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentLocation(Attachment $attachment): string
{
$path = storage_path('upload') . DIRECTORY_SEPARATOR . 'at-' . $attachment->id . '.data';
$path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, $attachment->id);
return $path;
}

View File

@ -28,6 +28,7 @@ class ForgotPasswordController extends Controller
*/
public function __construct()
{
parent::__construct();
$this->middleware('guest');
}
}

View File

@ -421,6 +421,7 @@ class ImportController extends Controller
{
// create proper importer (depends on job)
$type = $job->file_type;
/** @var SetupInterface $importer */
$importer = app('FireflyIII\Import\Setup\\' . ucfirst($type) . 'Setup');
$importer->setJob($job);

View File

@ -226,7 +226,7 @@ class TagController extends Controller
$subTitle = $tag->tag;
$subTitleIcon = 'fa-tag';
// TODO move to repository.
/** @var Collection $journals */
$journals = $tag

View File

@ -124,8 +124,9 @@ class CsvImporter implements ImporterInterface
$doMap = $config['column-do-mapping'][$rowIndex] ?? false;
$converterClass = config('csv.import_roles.' . $role . '.converter');
$mapping = $config['column-mapping-config'][$rowIndex] ?? [];
$className = sprintf('FireflyIII\\Import\\Converter\\%s', $converterClass);
/** @var ConverterInterface $converter */
$converter = app('FireflyIII\\Import\\Converter\\' . $converterClass);
$converter = app($className);
// set some useful values for the converter:
$converter->setMapping($mapping);
$converter->setDoMap($doMap);

View File

@ -216,9 +216,13 @@ class CsvSetup implements SetupInterface
// loop specifics.
if (isset($data['specifics']) && is_array($data['specifics'])) {
foreach ($data['specifics'] as $name => $enabled) {
// verify their content.
$className = sprintf('FireflyIII\Import\Specifics\%s', $name);
if (class_exists($className)) {
$config['specifics'][$name] = 1;
}
}
}
$this->job->configuration = $config;
$this->job->save();

View File

@ -11,6 +11,7 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\ImportJob;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ImportJob;
use FireflyIII\User;
use Illuminate\Support\Str;
@ -43,6 +44,12 @@ class ImportJobRepository implements ImportJobRepositoryInterface
public function create(string $fileType): ImportJob
{
$count = 0;
$fileType = strtolower($fileType);
$keys = array_keys(config('firefly.import_formats'));
if (!in_array($fileType, $keys)) {
throw new FireflyException(sprintf('Cannot use type "%s" for import job.', $fileType));
}
while ($count < 30) {
$key = Str::random(12);
$existing = $this->findByKey($key);

View File

@ -17,18 +17,18 @@ Route::group(
['middleware' => 'user-not-logged-in'], function () {
// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); #
Route::post('login', 'Auth\LoginController@login'); #
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
// Registration Routes...
Route::get('/register', ['uses' => 'Auth\RegisterController@showRegistrationForm', 'as' => 'register']); #
Route::post('/register', 'Auth\RegisterController@register'); #
Route::get('/register', ['uses' => 'Auth\RegisterController@showRegistrationForm', 'as' => 'register']);
Route::post('/register', 'Auth\RegisterController@register');
// Password Reset Routes...
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm'); #
Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail'); #
Route::post('/password/reset', 'Auth\ResetPasswordController@reset'); #
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm'); #
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm');
}