misc_pterodactyl-panel/app/Http/Middleware/Api/SetSessionDriver.php

40 lines
869 B
PHP
Raw Normal View History

2017-11-19 20:05:13 +00:00
<?php
namespace Pterodactyl\Http\Middleware\Api;
2017-11-19 20:05:13 +00:00
use Closure;
use Illuminate\Http\Request;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class SetSessionDriver
{
/**
* @var \Illuminate\Contracts\Config\Repository
*/
private $config;
/**
* SetSessionDriver constructor.
*
2018-07-05 02:38:23 +00:00
* @param \Illuminate\Contracts\Config\Repository $config
2017-11-19 20:05:13 +00:00
*/
2018-07-05 02:38:23 +00:00
public function __construct(ConfigRepository $config)
2017-11-19 20:05:13 +00:00
{
$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)
{
$this->config->set('session.driver', 'array');
return $next($request);
}
}