diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index e129fc9128..1d26e17f43 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -282,7 +282,7 @@ class AccountController extends Controller * * @return View */ - public function showWithDate(Account $account, string $date) + public function showByDate(Account $account, string $date) { $carbon = new Carbon($date); $range = Preferences::get('viewRange', '1M')->data; @@ -298,7 +298,7 @@ class AccountController extends Controller $journals = $collector->getPaginatedJournals(); $journals->setPath('accounts/show/' . $account->id . '/' . $date); - return view('accounts.show_with_date', compact('category', 'date', 'account', 'journals', 'subTitle', 'carbon', 'start', 'end')); + return view('accounts.show-by-date', compact('category', 'date', 'account', 'journals', 'subTitle', 'carbon', 'start', 'end')); } /** diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index d310cc3bd7..ae1af3c066 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -38,10 +38,16 @@ class TwoFactorController extends Controller $user = auth()->user(); // to make sure the validator in the next step gets the secret, we push it in session - $secret = Preferences::get('twoFactorAuthSecret', '')->data; + $secret = Preferences::get('twoFactorAuthSecret', null)->data; $title = strval(trans('firefly.two_factor_title')); - if (strlen($secret) === 0) { + // make sure the user has two factor configured: + $has2FA = Preferences::get('twoFactorAuthEnabled', null)->data; + if (is_null($has2FA) || $has2FA === false) { + return redirect(route('index')); + } + + if (strlen(strval($secret)) === 0) { throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.'); } Session::flash('two-factor-secret', $secret); diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index c0e8071327..fb586715de 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -112,7 +112,7 @@ class AccountController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function expenseByBudget(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end) + public function expenseBudget(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end) { $cache = new CacheProperties; $cache->addProperty($account->id); @@ -153,7 +153,7 @@ class AccountController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function expenseByCategory(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end) + public function expenseCategory(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end) { $cache = new CacheProperties; $cache->addProperty($account->id); @@ -199,7 +199,7 @@ class AccountController extends Controller $frontPage = Preferences::get('frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()); $accounts = $repository->getAccountsById($frontPage->data); - return Response::json($this->accountBalanceChart($start, $end, $accounts)); + return Response::json($this->accountBalanceChart($accounts, $start, $end)); } /** @@ -210,7 +210,7 @@ class AccountController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function incomeByCategory(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end) + public function incomeCategory(JournalCollectorInterface $collector, Account $account, Carbon $start, Carbon $end) { $cache = new CacheProperties; $cache->addProperty($account->id); @@ -251,9 +251,9 @@ class AccountController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function report(Carbon $start, Carbon $end, Collection $accounts) + public function report(Collection $accounts, Carbon $start, Carbon $end) { - return Response::json($this->accountBalanceChart($start, $end, $accounts)); + return Response::json($this->accountBalanceChart($accounts, $start, $end)); } /** @@ -406,13 +406,13 @@ class AccountController extends Controller } /** + * @param Collection $accounts * @param Carbon $start * @param Carbon $end - * @param Collection $accounts * * @return array */ - private function accountBalanceChart(Carbon $start, Carbon $end, Collection $accounts): array + private function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array { // chart properties for cache: $cache = new CacheProperties(); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 71089f6b81..655c3b2a22 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -61,14 +61,13 @@ class ReportController extends Controller } /** + * @param Collection $accounts * @param Carbon $start * @param Carbon $end - * @param Collection $accounts * * @return string - * @throws FireflyException */ - public function auditReport(Carbon $start, Carbon $end, Collection $accounts) + public function auditReport(Collection $accounts, Carbon $start, Carbon $end) { if ($end < $start) { return view('error')->with('message', trans('firefly.end_after_start_date')); @@ -97,15 +96,14 @@ class ReportController extends Controller } /** + * @param Collection $accounts + * @param Collection $categories * @param Carbon $start * @param Carbon $end - * @param Collection $accounts - * - * @param Collection $categories * * @return string */ - public function categoryReport(Carbon $start, Carbon $end, Collection $accounts, Collection $categories) + public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) { if ($end < $start) { return view('error')->with('message', trans('firefly.end_after_start_date')); @@ -134,14 +132,13 @@ class ReportController extends Controller } /** + * @param Collection $accounts * @param Carbon $start * @param Carbon $end - * @param Collection $accounts * * @return string - * @throws FireflyException */ - public function defaultReport(Carbon $start, Carbon $end, Collection $accounts) + public function defaultReport(Collection $accounts, Carbon $start, Carbon $end) { if ($end < $start) { return view('error')->with('message', trans('firefly.end_after_start_date')); @@ -246,13 +243,13 @@ class ReportController extends Controller default: throw new FireflyException(sprintf('Firefly does not support the "%s"-report yet.', $reportType)); case 'category': - $uri = route('reports.report.category', [$start, $end, $accounts, $categories]); + $uri = route('reports.report.category', [$accounts, $categories, $start, $end]); break; case 'default': - $uri = route('reports.report.default', [$start, $end, $accounts]); + $uri = route('reports.report.default', [$accounts, $start, $end]); break; case 'audit': - $uri = route('reports.report.audit', [$start, $end, $accounts]); + $uri = route('reports.report.audit', [$accounts, $start, $end]); break; } diff --git a/app/Http/Middleware/AuthenticateTwoFactor.php b/app/Http/Middleware/AuthenticateTwoFactor.php index 7dbaa77505..4f9f1f5542 100644 --- a/app/Http/Middleware/AuthenticateTwoFactor.php +++ b/app/Http/Middleware/AuthenticateTwoFactor.php @@ -57,7 +57,7 @@ class AuthenticateTwoFactor $has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); $is2faAuthed = Session::get('twofactor-authenticated'); if ($is2faEnabled && $has2faSecret && !$is2faAuthed) { - return redirect(route('two-factor')); + return redirect(route('two-factor.index')); } return $next($request); diff --git a/public/js/ff/accounts/show_with_date.js b/public/js/ff/accounts/show-by-date.js similarity index 88% rename from public/js/ff/accounts/show_with_date.js rename to public/js/ff/accounts/show-by-date.js index c34d4ce952..4e1768daf4 100644 --- a/public/js/ff/accounts/show_with_date.js +++ b/public/js/ff/accounts/show-by-date.js @@ -6,9 +6,6 @@ * of the MIT license. See the LICENSE file for details. */ -/* global $, lineChart, dateString, accountID, token, incomeByCategoryUri, expenseByCategoryUri, expenseByBudgetUri */ - - // Return a helper with preserved width of cells var fixHelper = function (e, tr) { "use strict"; @@ -24,11 +21,11 @@ var fixHelper = function (e, tr) { $(function () { "use strict"; - lineChart('chart/account/' + accountID + '/' + dateString, 'period-specific-account'); + lineChart(periodUri, 'period-specific-account'); - pieChart(incomeByCategoryUri, 'account-cat-in'); - pieChart(expenseByCategoryUri, 'account-cat-out'); - pieChart(expenseByBudgetUri, 'account-budget-out'); + pieChart(incomeCategoryUri, 'account-cat-in'); + pieChart(expenseCategoryUri, 'account-cat-out'); + pieChart(expenseBudgetUri, 'account-budget-out'); // sortable! diff --git a/public/js/ff/accounts/show.js b/public/js/ff/accounts/show.js index 4de17eddb5..5875c0da90 100644 --- a/public/js/ff/accounts/show.js +++ b/public/js/ff/accounts/show.js @@ -15,10 +15,10 @@ var fixHelper = function (e, tr) { $(function () { "use strict"; - lineChart('chart/account/' + accountID, 'overview-chart'); - pieChart(incomeByCategoryUri, 'account-cat-in'); - pieChart(expenseByCategoryUri, 'account-cat-out'); - pieChart(expenseByBudgetUri, 'account-budget-out'); + lineChart(singleUri, 'overview-chart'); + pieChart(incomeCategoryUri, 'account-cat-in'); + pieChart(expenseCategoryUri, 'account-cat-out'); + pieChart(expenseBudgetUri, 'account-budget-out'); // sortable! diff --git a/public/js/ff/bills/show.js b/public/js/ff/bills/show.js index d383023ead..ba12284cd3 100644 --- a/public/js/ff/bills/show.js +++ b/public/js/ff/bills/show.js @@ -2,8 +2,6 @@ $(function () { "use strict"; - if (typeof(columnChart) === 'function' && typeof(billID) !== 'undefined') { - columnChart('chart/bill/' + billID, 'bill-overview'); - } + columnChart(billUri, 'bill-overview'); } ); \ No newline at end of file diff --git a/public/js/ff/index.js b/public/js/ff/index.js index f797dcf142..b0cc90b70f 100644 --- a/public/js/ff/index.js +++ b/public/js/ff/index.js @@ -32,14 +32,14 @@ function endTheTour() { function drawChart() { "use strict"; - lineChart('chart/account/frontpage', 'accounts-chart'); + lineChart(accountFrontpageUri, 'accounts-chart'); if (billCount > 0) { pieChart('chart/bill/frontpage', 'bills-chart'); } stackedColumnChart('chart/budget/frontpage', 'budgets-chart'); columnChart('chart/category/frontpage', 'categories-chart'); - columnChart('chart/account/expense', 'expense-accounts-chart'); - columnChart('chart/account/revenue', 'revenue-accounts-chart'); + columnChart(accountExpenseUri, 'expense-accounts-chart'); + columnChart(accountRevenueUri, 'revenue-accounts-chart'); getBoxAmounts(); diff --git a/public/js/ff/reports/default/all.js b/public/js/ff/reports/default/all.js index 0d3f056e2b..939b0462e0 100644 --- a/public/js/ff/reports/default/all.js +++ b/public/js/ff/reports/default/all.js @@ -98,7 +98,7 @@ function displayAjaxPartial(data, holder) { function failAjaxPartial(uri, holder) { "use strict"; - console.log('Failed to load' + uri); + console.log('Failed to load: ' + uri); $('#' + holder).removeClass('loading').addClass('general-chart-error'); } diff --git a/public/js/ff/reports/default/month.js b/public/js/ff/reports/default/month.js index 4e34d95032..a150da25cc 100644 --- a/public/js/ff/reports/default/month.js +++ b/public/js/ff/reports/default/month.js @@ -15,5 +15,5 @@ function drawChart() { // month view: // draw account chart - lineChart('chart/account/report/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'account-balances-chart'); + lineChart(accountChartUri, 'account-balances-chart'); } \ No newline at end of file diff --git a/resources/views/accounts/edit.twig b/resources/views/accounts/edit.twig index d849fa50d4..0b76b53819 100644 --- a/resources/views/accounts/edit.twig +++ b/resources/views/accounts/edit.twig @@ -77,3 +77,7 @@ {{ Form.close|raw }} {% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/resources/views/accounts/show-by-date.twig b/resources/views/accounts/show-by-date.twig index e872140108..fbe746b110 100644 --- a/resources/views/accounts/show-by-date.twig +++ b/resources/views/accounts/show-by-date.twig @@ -94,9 +94,10 @@ var dateString = "{{ date|escape }}"; // uri's for charts: - var incomeByCategoryUri = '{{ route('chart.account.incomeByCategory', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; - var expenseByCategoryUri = '{{ route('chart.account.expenseByCategory', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; - var expenseByBudgetUri = '{{ route('chart.account.expenseByBudget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; + var periodUri = '{{ route('chart.account.single', [account.id, date]) }}'; + var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; + var expenseCategoryUri = '{{ route('chart.account.expense-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; + var expenseBudgetUri = '{{ route('chart.account.expense-budget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}'; @@ -104,6 +105,6 @@ - + {% endblock %} diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twig index 28f1b770b0..9826d1f358 100644 --- a/resources/views/accounts/show.twig +++ b/resources/views/accounts/show.twig @@ -123,9 +123,10 @@ diff --git a/resources/views/auth/two-factor.twig b/resources/views/auth/two-factor.twig index 65a29bed85..ea4275aae2 100644 --- a/resources/views/auth/two-factor.twig +++ b/resources/views/auth/two-factor.twig @@ -18,7 +18,7 @@
{{ trans('firefly.two_factor_welcome', {user: user.email}) }}
{{ 'two_factor_enter_code'|_ }}
- - {{ 'two_factor_forgot'|_ }} + {{ 'two_factor_forgot'|_ }} {% endblock %} diff --git a/resources/views/bills/show.twig b/resources/views/bills/show.twig index f2db32ebf2..9227d99d46 100644 --- a/resources/views/bills/show.twig +++ b/resources/views/bills/show.twig @@ -116,7 +116,7 @@ {% block scripts %} diff --git a/resources/views/budgets/income.twig b/resources/views/budgets/income.twig index aef412667c..f78cb2c255 100644 --- a/resources/views/budgets/income.twig +++ b/resources/views/budgets/income.twig @@ -8,7 +8,7 @@ -