Skip to content

Commit

Permalink
remove session start, and add web middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Recca Tsai committed Aug 18, 2016
1 parent 1c0f12f commit cf5995e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ return [
'router' => [
'prefix' => 'terminal',
'as' => 'terminal.',
'middleware' => ['web'], // if you use laravel 5.1 remove web
],
];

Expand Down
1 change: 1 addition & 0 deletions config/terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
'router' => [
'prefix' => 'terminal',
'as' => 'terminal.',
'middleware' => ['web'],
],
];
15 changes: 1 addition & 14 deletions src/Http/Controllers/TerminalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Recca0120\Terminal\Http\Controllers;

use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract;
use Illuminate\Contracts\Routing\UrlGenerator as UrlGeneratorContract;
Expand Down Expand Up @@ -52,29 +51,17 @@ class TerminalController extends Controller
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Session\SessionManager $sessionManager
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
*/
public function __construct(
ConsoleKernel $consoleKernel,
ApplicationContract $app,
SessionManager $sessionManager,
Request $request,
EncrypterContract $encrypter
Request $request
) {
$this->consoleKernel = $consoleKernel;
$this->app = $app;
$this->request = $request;
$this->session = $sessionManager->driver();

if ($this->app->runningInConsole() === false && $this->session->isStarted() === false) {
$sessionName = $request->cookies->get($this->session->getName());
$sessionName = ($this->session->isValidId($sessionName) === false) ?
$encrypter->decrypt($sessionName) :
$sessionName;
$this->session->setId($sessionName);
$this->session->setRequestOnHandler($request);
$this->session->start();
}
}

/**
Expand Down

0 comments on commit cf5995e

Please sign in to comment.