Get settings in middleware, makr available in views

This commit is contained in:
snipe 2016-11-28 22:53:16 -08:00
parent cc943e22db
commit 4c08331c9d
3 changed files with 28 additions and 3 deletions

View file

@ -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,
];
/**

View file

@ -19,13 +19,13 @@ class CheckForTwoFactor
public 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-authed

View 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);
}
}