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.
*/
public function onUserLogout($event)
public function onUserLogout()
{
// dump stuff from the session:
Session::forget('twofactor-authenticated');

View File

@ -64,26 +64,26 @@ class PreferencesController extends Controller
*/
public function index(ARI $repository)
{
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$budgetMax = Preferences::get('budgetMaximum', 1000);
$language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data;
$budgetMaximum = $budgetMax->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$twoFactorAuthEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data;
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$budgetMax = Preferences::get('budgetMaximum', 1000);
$language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data;
$budgetMaximum = $budgetMax->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;
return view(
'preferences.index',
compact(
'budgetMaximum', 'language', 'accounts', 'frontPageAccounts',
'viewRange', 'customFiscalYear', 'fiscalYearStart', 'twoFactorAuthEnabled',
'hasTwoFactorAuthSecret', 'showIncomplete'
'viewRange', 'customFiscalYear', 'fiscalYearStart', 'is2faEnabled',
'has2faSecret', 'showIncomplete'
)
);
}

View File

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

View File

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

View File

@ -150,12 +150,12 @@
<div class="checkbox">
<label>
<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>
</div>
</div>
{% if twoFactorAuthEnabled == 1 and hasTwoFactorAuthSecret == true %}
{% if is2faEnabled == 1 and has2faSecret == true %}
<div class="col-sm-10">
<div class="checkbox">