mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Get settings in middleware, makr available in views
This commit is contained in:
parent
cc943e22db
commit
4c08331c9d
|
@ -22,6 +22,7 @@ class Kernel extends HttpKernel
|
||||||
\App\Http\Middleware\NosniffGuard::class,
|
\App\Http\Middleware\NosniffGuard::class,
|
||||||
\App\Http\Middleware\CheckForSetup::class,
|
\App\Http\Middleware\CheckForSetup::class,
|
||||||
\Fideloper\Proxy\TrustProxies::class,
|
\Fideloper\Proxy\TrustProxies::class,
|
||||||
|
\App\Http\Middleware\GetAppSettings::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,13 +19,13 @@ class CheckForTwoFactor
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Skip the logic if the user is on the two factor pages
|
// 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()->getName()=='logout')) {
|
if (($request->route()->getName()=='two-factor') || ($request->route()->getName()=='two-factor-enroll') || ($request->route()->getPrefix()=='setup') || ($request->route()->getName()=='logout')) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two-factor is enabled (either optional or required)
|
// Two-factor is enabled (either optional or required)
|
||||||
if (Schema::hasTable('settings')) {
|
if (Setting::getSettings()) {
|
||||||
if (Auth::check() && (Setting::getSettings()->two_factor_enabled!='')) {
|
if (Auth::check() && (Setting::getSettings()->two_factor_enabled!='')) {
|
||||||
|
|
||||||
// This user is already 2fa-authed
|
// This user is already 2fa-authed
|
||||||
|
|
24
app/Http/Middleware/GetAppSettings.php
Normal file
24
app/Http/Middleware/GetAppSettings.php
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue