From 48209d0d22c16d437f249542fa7340ff15d3eb3f Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 26 Dec 2016 08:57:07 +0100 Subject: [PATCH] Demo user cannot enable two factor auth. --- app/Http/Controllers/HomeController.php | 2 +- app/Http/Controllers/PreferencesController.php | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 0cc0aa6e48..1abee2e11b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -108,7 +108,7 @@ class HomeController extends Controller $journal->save(); } } - Session::forget(['start','end','viewRange','range','is_custom_range']); + Session::forget(['start', 'end', 'viewRange', 'range', 'is_custom_range']); Session::clear(); Artisan::call('cache:clear'); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index a3654bb031..93efecf2a8 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -166,13 +166,17 @@ class PreferencesController extends Controller Preferences::set('transactionPageSize', 50); } - // two factor auth - $twoFactorAuthEnabled = intval($request->get('twoFactorAuthEnabled')); - $hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret')); + $twoFactorAuthEnabled = false; + $hasTwoFactorAuthSecret = false; + if (!auth()->user()->hasRole('demo')) { + // two factor auth + $twoFactorAuthEnabled = intval($request->get('twoFactorAuthEnabled')); + $hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret')); - // If we already have a secret, just set the two factor auth enabled to 1, and let the user continue with the existing secret. - if ($hasTwoFactorAuthSecret) { - Preferences::set('twoFactorAuthEnabled', $twoFactorAuthEnabled); + // If we already have a secret, just set the two factor auth enabled to 1, and let the user continue with the existing secret. + if ($hasTwoFactorAuthSecret) { + Preferences::set('twoFactorAuthEnabled', $twoFactorAuthEnabled); + } } // language: