This commit is contained in:
James Cole 2017-12-19 19:25:50 +01:00
parent e21e339cb0
commit a69aad878e
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
25 changed files with 114 additions and 33 deletions

View File

@ -23,7 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\ConfigurationRequest;
use FireflyIII\Support\Facades\FireflyConfig;
use Preferences;
@ -51,7 +52,8 @@ class ConfigurationController extends Controller
return $next($request);
}
);
$this->middleware(IsLimitedUser::class)->except(['index']);
$this->middleware(IsDemoUser::class)->except(['index']);
$this->middleware(IsSandStormUser::class);
}
/**

View File

@ -24,7 +24,8 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use Illuminate\Http\Request;
use Log;
use Session;
@ -40,7 +41,8 @@ class HomeController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(IsLimitedUser::class)->except(['index']);
$this->middleware(IsDemoUser::class)->except(['index']);
$this->middleware(IsSandStormUser::class)->except(['index']);
}

View File

@ -23,7 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\LinkTypeFormRequest;
use FireflyIII\Models\LinkType;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
@ -51,7 +52,7 @@ class LinkController extends Controller
return $next($request);
}
);
$this->middleware(IsLimitedUser::class)->except(['index', 'show']);
$this->middleware(IsDemoUser::class)->except(['index', 'show']);
}
/**

View File

@ -23,7 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\UserFormRequest;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
@ -52,7 +53,8 @@ class UserController extends Controller
return $next($request);
}
);
$this->middleware(IsLimitedUser::class)->except(['index', 'show']);
$this->middleware(IsDemoUser::class)->except(['index', 'show']);
$this->middleware(IsSandStormUser::class);
}
/**

View File

@ -27,7 +27,8 @@ use Carbon\Carbon;
use DB;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
@ -55,7 +56,8 @@ class HomeController extends Controller
parent::__construct();
app('view')->share('title', 'Firefly III');
app('view')->share('mainTitleIcon', 'fa-fire');
$this->middleware(IsLimitedUser::class)->except(['dateRange', 'index']);
$this->middleware(IsDemoUser::class)->except(['dateRange', 'index']);
$this->middleware(IsSandStormUser::class)->only('routes');
}
/**

View File

@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Import\Configuration\ConfiguratorInterface;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
@ -57,7 +57,7 @@ class ConfigurationController extends Controller
return $next($request);
}
);
$this->middleware(IsLimitedUser::class)->except(['index']);
$this->middleware(IsDemoUser::class)->except(['index']);
}
/**

View File

@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Import\Routine\ImportRoutine;
use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Models\ImportJob;
@ -61,7 +61,7 @@ class IndexController extends Controller
}
);
$this->middleware(IsLimitedUser::class)->except(['create','index']);
$this->middleware(IsDemoUser::class)->except(['create','index']);
}
/**

View File

@ -26,7 +26,8 @@ use Auth;
use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Exceptions\ValidationException;
use FireflyIII\Http\Middleware\IsLimitedUser;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
use FireflyIII\Http\Requests\EmailFormRequest;
use FireflyIII\Http\Requests\ProfileFormRequest;
@ -62,7 +63,8 @@ class ProfileController extends Controller
return $next($request);
}
);
$this->middleware(IsLimitedUser::class)->except(['confirmEmailChange', 'index', 'undoEmailChange']);
$this->middleware(IsDemoUser::class)->except(['index']);
$this->middleware(IsSandStormUser::class)->except('index');
}
/**

View File

@ -1,6 +1,6 @@
<?php
/**
* IsLimitedUser.php
* IsDemoUser.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
@ -29,9 +29,9 @@ use Illuminate\Support\Facades\Auth;
use Session;
/**
* Class IsAdmin.
* Class IsDemoUser.
*/
class IsLimitedUser
class IsDemoUser
{
/**
* Handle an incoming request. May not be a limited user (ie. Sandstorm env. or demo user).
@ -59,12 +59,6 @@ class IsLimitedUser
return redirect(route('index'));
}
if (1 === intval(getenv('SANDSTORM'))) {
Session::flash('warning', strval(trans('firefly.sandstorm_not_available')));
return redirect(route('index'));
}
return $next($request);
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* IsSandStormUser.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Session;
/**
* Class IsSandStormUser.
*/
class IsSandStormUser
{
/**
* Handle an incoming request. May not be a limited user (ie. Sandstorm env. or demo user).
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle(Request $request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
}
return redirect()->guest('login');
}
if (1 === intval(getenv('SANDSTORM'))) {
Session::flash('warning', strval(trans('firefly.sandstorm_not_available')));
return redirect(route('index'));
}
return $next($request);
}
}

View File

@ -308,7 +308,7 @@ class CsvProcessor implements FileProcessorInterface
private function specifics(array $row): array
{
$config = $this->job->configuration;
$names = array_keys($config['specifics']);
$names = array_keys($config['specifics'] ?? []);
foreach ($names as $name) {
if (!in_array($name, $this->validSpecifics)) {
throw new FireflyException(sprintf('"%s" is not a valid class name', $name));

View File

@ -55,9 +55,11 @@ class Initial implements ConfigurationInterface
// update job with default date format:
$config = $this->job->configuration;
$config['date-format'] = 'Ymd';
$this->job->configuration = $config;
$this->job->save();
if (!isset($config['date-format'])) {
$config['date-format'] = 'Ymd';
$this->job->configuration = $config;
$this->job->save();
}
$specifics = [];
// collect specifics.

View File

@ -163,7 +163,7 @@ function jobIsStalled(data) {
function startJob() {
// disable the button, add loading thing.
$('.start-job').prop('disabled', true).text('...');
$.post(jobStartUri).fail(reportOnSubmitError);
$.post(jobStartUri, {_token: token}).fail(reportOnSubmitError);
// check status, every 500 ms.
timeOutId = setTimeout(checkJobStatus, startInterval);

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
/*

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'home' => 'Home',
'edit_currency' => 'Edit currency ":name"',
@ -29,7 +30,7 @@ return [
'preferences' => 'Preferences',
'profile' => 'Profile',
'changePassword' => 'Change your password',
'change_email' => 'Change your email address',
'change_email' => 'Change your email address',
'bills' => 'Bills',
'newBill' => 'New bill',
'edit_bill' => 'Edit bill ":name"',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'locale' => 'en, English, en_US, en_US.utf8, en_US.UTF-8',
'month' => '%B %Y',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'no_demo_text' => 'Sorry, there is no extra demo-explanation text for <abbr title=":route">this page</abbr>.',
'see_help_icon' => 'However, the <i class="fa fa-question-circle"></i>-icon in the top right corner may tell you more.',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
// new user:
@ -200,7 +201,7 @@ return [
'app_secret' => 'App secret',
'public_key' => 'Public key',
'country_code' => 'Country code',
'provider_code' => 'Bank or data-provider',
'provider_code' => 'Bank or data-provider',
'due_date' => 'Due date',

View File

@ -36,6 +36,7 @@ return [
'status_ready_start' => 'Start the import',
'status_ready_share' => 'Please consider downloading your configuration and sharing it at the <strong><a href="https://github.com/firefly-iii/import-configurations/wiki">import configuration center</a></strong>. This will allow other users of Firefly III to import their files more easily.',
'status_job_running' => 'The import is running.. Please wait..',
'status_job_finished' => 'The import has finished!',
'status_running_title' => 'The import is running',
'status_running_placeholder' => 'Please hold for an update...',
'status_finished_title' => 'Import routine finished',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
// index
'index_intro' => 'Welcome to the index page of Firefly III. Please take the time to walk through this intro to get a feeling of how Firefly III works.',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'buttons' => 'Buttons',
'icon' => 'Icon',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'previous' => '&laquo; Previous',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'password' => 'Passwords must be at least six characters and match the confirmation.',
'user' => 'We can\'t find a user with that e-mail address.',

View File

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
return [
'iban' => 'This is not a valid IBAN.',
'unique_account_number_for_user' => 'It looks like this account number is already in use.',

View File

@ -162,7 +162,7 @@
<a class="{{ activeRoutePartial('currencies') }}" href="{{ route('currencies.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currencies'|_ }}</a>
</li>
<!-- admin (if user admin) -->
{% if Auth.user.hasRole('owner') and not SANDSTORM %}
{% if Auth.user.hasRole('owner') %}
<li class="{{ activeRoutePartial('admin') }}">
<a class="{{ activeRoutePartial('admin') }}" href="{{ route('admin.index') }}"><i
class="fa fa-hand-spock-o fa-fw"></i> {{ 'administration'|_ }}</a>