mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 15:26:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Pterodactyl\Http\Middleware\Api;
 | 
						|
 | 
						|
use Closure;
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Barryvdh\Debugbar\LaravelDebugbar;
 | 
						|
use Illuminate\Contracts\Foundation\Application;
 | 
						|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
 | 
						|
 | 
						|
class SetSessionDriver
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @var \Illuminate\Contracts\Foundation\Application
 | 
						|
     */
 | 
						|
    private $app;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var \Illuminate\Contracts\Config\Repository
 | 
						|
     */
 | 
						|
    private $config;
 | 
						|
 | 
						|
    /**
 | 
						|
     * SetSessionDriver constructor.
 | 
						|
     *
 | 
						|
     * @param \Illuminate\Contracts\Foundation\Application $app
 | 
						|
     * @param \Illuminate\Contracts\Config\Repository      $config
 | 
						|
     */
 | 
						|
    public function __construct(Application $app, ConfigRepository $config)
 | 
						|
    {
 | 
						|
        $this->app = $app;
 | 
						|
        $this->config = $config;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Set the session for API calls to only last for the one request.
 | 
						|
     *
 | 
						|
     * @param \Illuminate\Http\Request $request
 | 
						|
     * @param \Closure                 $next
 | 
						|
     * @return mixed
 | 
						|
     */
 | 
						|
    public function handle(Request $request, Closure $next)
 | 
						|
    {
 | 
						|
        if ($this->config->get('app.debug')) {
 | 
						|
            $this->app->make(LaravelDebugbar::class)->disable();
 | 
						|
        }
 | 
						|
 | 
						|
        $this->config->set('session.driver', 'array');
 | 
						|
 | 
						|
        return $next($request);
 | 
						|
    }
 | 
						|
}
 |