Fixing routes

This commit is contained in:
James Cole
2016-12-06 06:52:17 +01:00
parent 9cb3bfaa57
commit bebfbf0b90
25 changed files with 103 additions and 91 deletions

View File

@@ -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'));
}
/**

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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);