Tweak how console commands are registered.
This commit is contained in:
39
app/Http/Middleware/VerifyCsrfToken.php
Normal file
39
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
|
||||
class VerifyCsrfToken implements Middleware {
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*
|
||||
* @throws TokenMismatchException
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->method() == 'GET' || $this->tokensMatch($request))
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
throw new TokenMismatchException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the session and input CSRF tokens match.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return bool
|
||||
*/
|
||||
protected function tokensMatch($request)
|
||||
{
|
||||
return $request->session()->token() == $request->input('_token');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user