Rename GuestUser to ApplicationSession as middleware to hold any site wide variables
This commit is contained in:
parent
e0fb057c84
commit
35596ec867
@ -22,7 +22,7 @@ class APIController extends Controller
|
|||||||
$dn = Crypt::decryptString($request->query('key'));
|
$dn = Crypt::decryptString($request->query('key'));
|
||||||
Log::debug(sprintf('%s: Query [%s] - Levels [%d]',__METHOD__,$dn,$levels));
|
Log::debug(sprintf('%s: Query [%s] - Levels [%d]',__METHOD__,$dn,$levels));
|
||||||
|
|
||||||
return (new Server())
|
return (config('server'))
|
||||||
->children($dn)
|
->children($dn)
|
||||||
->transform(function($item) {
|
->transform(function($item) {
|
||||||
return [
|
return [
|
||||||
|
@ -54,7 +54,7 @@ class HomeController extends Controller
|
|||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
// Load our attributes
|
// Load our attributes
|
||||||
$s = new Server;
|
$s = config('server');
|
||||||
$s->schema('objectclasses');
|
$s->schema('objectclasses');
|
||||||
$s->schema('attributetypes');
|
$s->schema('attributetypes');
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class HomeController extends Controller
|
|||||||
$dn = Crypt::decryptString($request->post('key'));
|
$dn = Crypt::decryptString($request->post('key'));
|
||||||
|
|
||||||
return view('frames.dn')
|
return view('frames.dn')
|
||||||
->with('o',(new Server)->fetch($dn))
|
->with('o',config('server')->fetch($dn))
|
||||||
->with('dn',$dn);
|
->with('dn',$dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function schema_frame(Request $request)
|
public function schema_frame(Request $request)
|
||||||
{
|
{
|
||||||
$s = new Server;
|
$s = config('server');
|
||||||
|
|
||||||
// If an invalid key, we'll 404
|
// If an invalid key, we'll 404
|
||||||
if ($request->type && $request->key && ($s->schema($request->type)->has($request->key) === FALSE))
|
if ($request->type && $request->key && ($s->schema($request->type)->has($request->key) === FALSE))
|
||||||
|
@ -4,9 +4,7 @@ namespace App\Http;
|
|||||||
|
|
||||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
use App\Http\Middleware\GuestUser;
|
use App\Http\Middleware\{ApplicationSession,CheckUpdate,SwapinAuthUser};
|
||||||
use App\Http\Middleware\SwapinAuthUser;
|
|
||||||
use App\Http\Middleware\CheckUpdate;
|
|
||||||
|
|
||||||
class Kernel extends HttpKernel
|
class Kernel extends HttpKernel
|
||||||
{
|
{
|
||||||
@ -43,7 +41,7 @@ class Kernel extends HttpKernel
|
|||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
|
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
|
||||||
GuestUser::class,
|
ApplicationSession::class,
|
||||||
CheckUpdate::class,
|
CheckUpdate::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -51,6 +49,7 @@ class Kernel extends HttpKernel
|
|||||||
'throttle:60,1',
|
'throttle:60,1',
|
||||||
\App\Http\Middleware\EncryptCookies::class,
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
SwapinAuthUser::class,
|
SwapinAuthUser::class,
|
||||||
|
ApplicationSession::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
29
app/Http/Middleware/ApplicationSession.php
Normal file
29
app/Http/Middleware/ApplicationSession.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Classes\LDAP\Server;
|
||||||
|
use App\Ldap\User;
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This sets up our application session with any required values, ultimately for cache optimisation reasons
|
||||||
|
*/
|
||||||
|
class ApplicationSession
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request,Closure $next)
|
||||||
|
{
|
||||||
|
view()->share('user', auth()->user() ?: new User);
|
||||||
|
|
||||||
|
\Config::set('server',new Server);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use App\Ldap\User;
|
|
||||||
use Closure;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class GuestUser
|
|
||||||
* @package Leenooks\Laravel\Http\Middleware
|
|
||||||
*/
|
|
||||||
class GuestUser
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle an incoming request.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @param \Closure $next
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle($request,Closure $next)
|
|
||||||
{
|
|
||||||
view()->share('user', auth()->user() ?: new User);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user