Some scrutiniser related code cleanup.

This commit is contained in:
James Cole
2016-03-20 16:46:26 +01:00
parent 6698b57f52
commit 6602b1587a
5 changed files with 26 additions and 26 deletions

View File

@@ -21,7 +21,7 @@ class UserEventListener
/** /**
* Handle user logout events. * Handle user logout events.
*/ */
public function onUserLogout($event) public function onUserLogout()
{ {
// dump stuff from the session: // dump stuff from the session:
Session::forget('twofactor-authenticated'); Session::forget('twofactor-authenticated');

View File

@@ -74,16 +74,16 @@ class PreferencesController extends Controller
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data; $customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data; $fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr; $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$twoFactorAuthEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; $is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret')); $has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true; $showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;
return view( return view(
'preferences.index', 'preferences.index',
compact( compact(
'budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'budgetMaximum', 'language', 'accounts', 'frontPageAccounts',
'viewRange', 'customFiscalYear', 'fiscalYearStart', 'twoFactorAuthEnabled', 'viewRange', 'customFiscalYear', 'fiscalYearStart', 'is2faEnabled',
'hasTwoFactorAuthSecret', 'showIncomplete' 'has2faSecret', 'showIncomplete'
) )
); );
} }

View File

@@ -52,10 +52,10 @@ class AuthenticateTwoFactor
return redirect()->guest('login'); return redirect()->guest('login');
} }
} }
$twoFactorAuthEnabled = Preferences::get('twoFactorAuthEnabled', false)->data; $is2faEnabled = Preferences::get('twoFactorAuthEnabled', false)->data;
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret')); $has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$isTwoFactorAuthenticated = Session::get('twofactor-authenticated'); $is2faAuthed = Session::get('twofactor-authenticated');
if ($twoFactorAuthEnabled && $hasTwoFactorAuthSecret && !$isTwoFactorAuthenticated) { if ($is2faEnabled && $has2faSecret && !$is2faAuthed) {
return redirect(route('two-factor')); return redirect(route('two-factor'));
} }

View File

@@ -36,10 +36,10 @@ class RedirectIfTwoFactorAuthenticated
{ {
if (Auth::guard($guard)->check()) { if (Auth::guard($guard)->check()) {
$twoFactorAuthEnabled = Preferences::get('twoFactorAuthEnabled', false)->data; $is2faEnabled = Preferences::get('twoFactorAuthEnabled', false)->data;
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret')); $has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$isTwoFactorAuthenticated = Session::get('twofactor-authenticated'); $is2faAuthed = Session::get('twofactor-authenticated');
if ($twoFactorAuthEnabled && $hasTwoFactorAuthSecret && $isTwoFactorAuthenticated) { if ($is2faEnabled && $has2faSecret && $is2faAuthed) {
return redirect('/'); return redirect('/');
} }
} }

View File

@@ -150,12 +150,12 @@
<div class="checkbox"> <div class="checkbox">
<label> <label>
<input type="checkbox" name="twoFactorAuthEnabled" value="1" <input type="checkbox" name="twoFactorAuthEnabled" value="1"
{% if twoFactorAuthEnabled == '1' %} checked {% endif %}> {{ 'pref_enable_two_factor_auth'|_ }} {% if is2faEnabled == '1' %} checked {% endif %}> {{ 'pref_enable_two_factor_auth'|_ }}
</label> </label>
</div> </div>
</div> </div>
{% if twoFactorAuthEnabled == 1 and hasTwoFactorAuthSecret == true %} {% if is2faEnabled == 1 and has2faSecret == true %}
<div class="col-sm-10"> <div class="col-sm-10">
<div class="checkbox"> <div class="checkbox">