From e8e0a44cca480f31f3f3c7c4d66ca122e1ca4e0f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 18 Nov 2017 16:30:45 +0100 Subject: [PATCH] Fix for #1002 --- app/Http/Controllers/AccountController.php | 2 +- app/Http/Controllers/Auth/LoginController.php | 5 +++-- app/Http/Controllers/Auth/TwoFactorController.php | 6 +++--- app/Http/Controllers/HomeController.php | 4 ++-- app/Http/Controllers/JavascriptController.php | 2 +- app/Http/Controllers/NewUserController.php | 1 - app/Http/Controllers/ProfileController.php | 1 + app/Http/Controllers/Transaction/MassController.php | 4 +--- app/Http/Middleware/AuthenticateTwoFactor.php | 4 ++-- app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php | 4 ++-- app/Repositories/Budget/BudgetRepository.php | 2 +- 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index ebbd721bbe..ea1c6ba692 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -409,7 +409,7 @@ class AccountController extends Controller * and for each period, the amount of money spent and earned. This is a complex operation which is cached for * performance reasons. * - * @param Account $account The account involved. + * @param Account $account the account involved * * @return Collection * diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index c826709f8f..b6d80cf1ca 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -101,7 +101,7 @@ class LoginController extends Controller } // forget 2fa cookie: - $cookie = $cookieJar->forever('twoFactorAuthenticated', 'false'); + $request->session()->forget('twoFactorAuthenticated'); // is allowed to? $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; @@ -114,6 +114,7 @@ class LoginController extends Controller $email = $request->old('email'); $remember = $request->old('remember'); - return view('auth.login', compact('allowRegistration', 'email', 'remember'))->withCookie($cookie); + + return view('auth.login', compact('allowRegistration', 'email', 'remember'));//->withCookie($cookie); } } diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index 79bc49041e..5924d5be9e 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -96,9 +96,9 @@ class TwoFactorController extends Controller */ public function postIndex(TokenFormRequest $request, CookieJar $cookieJar) { - // set cookie! - $cookie = $cookieJar->forever('twoFactorAuthenticated', 'true'); + // update session, not cookie: + $request->session()->put('twoFactorAuthenticated', true); - return redirect(route('home'))->withCookie($cookie); + return redirect(route('home')); } } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index dec3344e4b..0632f35c37 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -94,7 +94,7 @@ class HomeController extends Controller { $phpVersion = PHP_VERSION; $phpOs = php_uname(); - $interface = php_sapi_name(); + $interface = PHP_SAPI; $now = Carbon::create()->format('Y-m-d H:i:s e'); $extensions = join(', ', get_loaded_extensions()); $drivers = join(', ', DB::availableDrivers()); @@ -211,7 +211,7 @@ class HomeController extends Controller return view( 'index', - compact('count', 'subTitle', 'transactions', 'showDeps', 'billCount','start','end','today') + compact('count', 'subTitle', 'transactions', 'showDeps', 'billCount', 'start', 'end', 'today') ); } diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 4c310de894..6ec063da76 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -100,7 +100,7 @@ class JavascriptController extends Controller $currencyId = intval($account->getMeta('currency_id')); } /** @var TransactionCurrency $currency */ - $currency = $currencyRepository->find($currencyId); + $currency = $currencyRepository->find($currencyId); if (0 === $currencyId) { $currency = app('amount')->getDefaultCurrency(); } diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index d1f9df1556..efa5ae5ab7 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -72,7 +72,6 @@ class NewUserController extends Controller /** * @param NewUserFormRequest $request * @param AccountRepositoryInterface $repository - * * @param CurrencyRepositoryInterface $currencyRepository * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 0ee347e9fb..95d9fe440c 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -261,6 +261,7 @@ class ProfileController extends Controller * @param string $hash * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws FireflyException */ public function undoEmailChange(string $token, string $hash) diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index d7dc44935b..ed25b29bf6 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -133,9 +133,7 @@ class MassController extends Controller // skip transactions that have multiple destinations, multiple sources or are an opening balance. $filtered = new Collection; $messages = []; - /** - * @var TransactionJournal - */ + // @var TransactionJournal foreach ($journals as $journal) { $sources = $journal->sourceAccountList(); $destinations = $journal->destinationAccountList(); diff --git a/app/Http/Middleware/AuthenticateTwoFactor.php b/app/Http/Middleware/AuthenticateTwoFactor.php index 970e834cbc..8b0ae9e071 100644 --- a/app/Http/Middleware/AuthenticateTwoFactor.php +++ b/app/Http/Middleware/AuthenticateTwoFactor.php @@ -64,8 +64,8 @@ class AuthenticateTwoFactor $is2faEnabled = Preferences::get('twoFactorAuthEnabled', false)->data; $has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); - // grab 2auth information from cookie, not from session. - $is2faAuthed = 'true' === Cookie::get('twoFactorAuthenticated'); + // grab 2auth information from session. + $is2faAuthed = true === $request->session()->get('twoFactorAuthenticated'); if ($is2faEnabled && $has2faSecret && !$is2faAuthed) { Log::debug('Does not seem to be 2 factor authed, redirect.'); diff --git a/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php b/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php index 1e63bb21da..7b379fd462 100644 --- a/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php +++ b/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php @@ -47,8 +47,8 @@ class RedirectIfTwoFactorAuthenticated $is2faEnabled = Preferences::get('twoFactorAuthEnabled', false)->data; $has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); - // grab 2auth information from cookie - $is2faAuthed = 'true' === Cookie::get('twoFactorAuthenticated'); + // grab 2auth information from session. + $is2faAuthed = true === $request->session()->get('twoFactorAuthenticated'); if ($is2faEnabled && $has2faSecret && $is2faAuthed) { return redirect('/'); diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 88c2872307..f5329ab466 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -87,7 +87,7 @@ class BudgetRepository implements BudgetRepositoryInterface /** @var AccountRepositoryInterface $accountRepository */ $accountRepository = app(AccountRepositoryInterface::class); $accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); - $defaultCurrency = app('amount')->getDefaultCurrency(); + $defaultCurrency = app('amount')->getDefaultCurrency(); $return = []; /** @var Budget $budget */ foreach ($budgets as $budget) {