Skip to content

Firefly III: a personal finances manager

Some scrutiniser related code cleanup.

James Cole6602b1587a9d
diff --git a/app/Handlers/Events/UserEventListener.php b/app/Handlers/Events/UserEventListener.php
index 6bfdbb75bd..1b3888ec0c 100644
--- a/app/Handlers/Events/UserEventListener.php
+++ b/app/Handlers/Events/UserEventListener.php
@@ -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');
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index bbfdc7941c..e84245a4d6 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -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'
)
);
}
diff --git a/app/Http/Middleware/AuthenticateTwoFactor.php b/app/Http/Middleware/AuthenticateTwoFactor.php
index a27ba70151..13e62673f1 100644
--- a/app/Http/Middleware/AuthenticateTwoFactor.php
+++ b/app/Http/Middleware/AuthenticateTwoFactor.php
@@ -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'));
}
diff --git a/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php b/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php
index a918d515b4..682e2f09d6 100644
--- a/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php
@@ -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('/');
}
}
diff --git a/resources/views/preferences/index.twig b/resources/views/preferences/index.twig
index 5dd4882713..a78117cacf 100644
--- a/resources/views/preferences/index.twig
+++ b/resources/views/preferences/index.twig
@@ -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">