This commit is contained in:
James Cole 2017-02-16 21:01:22 +01:00
parent c8f6b42ce6
commit 8bfcc3315a
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 12 additions and 6 deletions

View File

@ -17,6 +17,7 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\TokenFormRequest; use FireflyIII\Http\Requests\TokenFormRequest;
use Illuminate\Http\Request;
use Log; use Log;
use Preferences; use Preferences;
use Session; use Session;
@ -30,11 +31,14 @@ class TwoFactorController extends Controller
{ {
/** /**
* @return mixed * @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @throws FireflyException * @throws FireflyException
*/ */
public function index() public function index(Request $request)
{ {
$user = auth()->user(); $user = auth()->user();
// to make sure the validator in the next step gets the secret, we push it in session // to make sure the validator in the next step gets the secret, we push it in session
@ -50,7 +54,7 @@ class TwoFactorController extends Controller
if (strlen(strval($secret)) === 0) { 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.'); 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); $request->session()->flash('two-factor-secret', $secret);
return view('auth.two-factor', compact('user', 'title')); return view('auth.two-factor', compact('user', 'title'));
} }

View File

@ -13,6 +13,7 @@ namespace FireflyIII\Http\Controllers;
use Amount; use Amount;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use Illuminate\Http\Request;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Session; use Session;
@ -28,7 +29,7 @@ class JavascriptController extends Controller
/** /**
* *
*/ */
public function variables() public function variables(Request $request)
{ {
$picker = $this->getDateRangePicker(); $picker = $this->getDateRangePicker();
$start = Session::get('start'); $start = Session::get('start');
@ -52,6 +53,7 @@ class JavascriptController extends Controller
'localeconv' => $localeconv, 'localeconv' => $localeconv,
'language' => $lang, 'language' => $lang,
]; ];
$request->session()->keep(['two-factor-secret']);
return response() return response()
->view('javascript.variables', $data, 200) ->view('javascript.variables', $data, 200)

View File

@ -56,9 +56,9 @@ class PreferencesController extends Controller
{ {
$domain = $this->getDomain(); $domain = $this->getDomain();
/** @noinspection PhpMethodParametersCountMismatchInspection */ /** @noinspection PhpMethodParametersCountMismatchInspection */
$secret = $google2fa->generateSecretKey(16, auth()->user()->id); $secret = $google2fa->generateSecretKey(32, auth()->user()->id);
Session::flash('two-factor-secret', $secret); Session::flash('two-factor-secret', $secret);
$image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, null, $secret, 150); $image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, auth()->user()->email, $secret, 150);
return view('preferences.code', compact('image')); return view('preferences.code', compact('image'));