A free open source IT asset/license management system
Get settings in middleware, makr available in views
snipe4c08331c9dd7
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.phpindex 61d14dcf58..209295e75a 100644--- a/app/Http/Kernel.php+++ b/app/Http/Kernel.php@@ -22,6 +22,7 @@ class Kernel extends HttpKernel\App\Http\Middleware\NosniffGuard::class,\App\Http\Middleware\CheckForSetup::class,\Fideloper\Proxy\TrustProxies::class,+ \App\Http\Middleware\GetAppSettings::class,];/**diff --git a/app/Http/Middleware/CheckForTwoFactor.php b/app/Http/Middleware/CheckForTwoFactor.phpindex 476e9fdd57..61dcf52690 100644--- a/app/Http/Middleware/CheckForTwoFactor.php+++ b/app/Http/Middleware/CheckForTwoFactor.php@@ -19,13 +19,13 @@ class CheckForTwoFactorpublic function handle($request, Closure $next){- // Skip the logic if the user is on the two factor pages- if (($request->route()->getName()=='two-factor') || ($request->route()->getName()=='two-factor-enroll') || ($request->route()->getName()=='logout')) {+ // Skip the logic if the user is on the two factor pages or the setup pages+ if (($request->route()->getName()=='two-factor') || ($request->route()->getName()=='two-factor-enroll') || ($request->route()->getPrefix()=='setup') || ($request->route()->getName()=='logout')) {return $next($request);}// Two-factor is enabled (either optional or required)- if (Schema::hasTable('settings')) {+ if (Setting::getSettings()) {if (Auth::check() && (Setting::getSettings()->two_factor_enabled!='')) {// This user is already 2fa-autheddiff --git a/app/Http/Middleware/GetAppSettings.php b/app/Http/Middleware/GetAppSettings.phpnew file mode 100644index 0000000000..e8340e8fff--- /dev/null+++ b/app/Http/Middleware/GetAppSettings.php@@ -0,0 +1,24 @@+<?php++namespace App\Http\Middleware;++use App\Models\Setting;++use Closure;++class GetAppSettings+{+ /**+ * Handle an incoming request.+ *+ * @param \Illuminate\Http\Request $request+ * @param \Closure $next+ * @return mixed+ */+ public function handle($request, Closure $next)+ {+ $app_settings = Setting::getSettings();+ view()->share('app_settings', $app_settings);+ return $next($request);+ }+}