From e92aa7942ee79779e6064a3859dcd43254e790d7 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Thu, 30 May 2024 12:15:15 -0400 Subject: [PATCH 1/2] Adding functionality to handle 2fa on and off in jetstream --- src/AuthServiceProvider.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/AuthServiceProvider.php b/src/AuthServiceProvider.php index 56d95ca..0700b35 100644 --- a/src/AuthServiceProvider.php +++ b/src/AuthServiceProvider.php @@ -7,6 +7,7 @@ use Devdojo\Auth\Http\Middleware\ViewAuthSetup; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Route; +use Illuminate\Support\Facades\Config; use Illuminate\Support\ServiceProvider; use Laravel\Folio\Folio; use Livewire\Livewire; @@ -78,7 +79,7 @@ public function boot(): void Livewire::component('auth.setup.css', \Devdojo\Auth\Livewire\Setup\Css::class); } - //app()->register(\October\Rain\Config\ServiceProvider::class); + $this->handleStarterKitFunctionality(); } private function registerAuthFolioDirectory(): void @@ -100,6 +101,23 @@ private function registerVoltDirectory(): void ]); } + private function handleStarterKitFunctionality(){ + $this->jetstreamFunctionality(); + } + + private function jetstreamFunctionality(){ + // We check if fortify is installed and the user has enabled 2FA, if so we want to enable that feature + if (class_exists(\Laravel\Fortify\Features::class) && config('devdojo.auth.settings.enable_2fa')) { + Config::set('fortify.features', array_merge( + Config::get('fortify.features', []), + [ + \Laravel\Fortify\Features::twoFactorAuthentication([ + 'confirmPassword' => true, + ]) + ] + )); + } + } /** * Register the application services. */ From dd7d192bb833adcd9c65c927307093f1f121a1cf Mon Sep 17 00:00:00 2001 From: tnylea Date: Thu, 30 May 2024 16:15:49 +0000 Subject: [PATCH 2/2] Fixes coding style --- src/AuthServiceProvider.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AuthServiceProvider.php b/src/AuthServiceProvider.php index 0700b35..c1ed580 100644 --- a/src/AuthServiceProvider.php +++ b/src/AuthServiceProvider.php @@ -5,9 +5,9 @@ use Devdojo\Auth\Http\Middleware\TwoFactorChallenged; use Devdojo\Auth\Http\Middleware\TwoFactorEnabled; use Devdojo\Auth\Http\Middleware\ViewAuthSetup; +use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Route; -use Illuminate\Support\Facades\Config; use Illuminate\Support\ServiceProvider; use Laravel\Folio\Folio; use Livewire\Livewire; @@ -101,11 +101,13 @@ private function registerVoltDirectory(): void ]); } - private function handleStarterKitFunctionality(){ + private function handleStarterKitFunctionality() + { $this->jetstreamFunctionality(); } - private function jetstreamFunctionality(){ + private function jetstreamFunctionality() + { // We check if fortify is installed and the user has enabled 2FA, if so we want to enable that feature if (class_exists(\Laravel\Fortify\Features::class) && config('devdojo.auth.settings.enable_2fa')) { Config::set('fortify.features', array_merge( @@ -113,11 +115,12 @@ private function jetstreamFunctionality(){ [ \Laravel\Fortify\Features::twoFactorAuthentication([ 'confirmPassword' => true, - ]) + ]), ] )); } } + /** * Register the application services. */