CsrfMiddleware.php 524 B

1234567891011121314151617181920212223242526
  1. <?php namespace App\Http\Middleware;
  2. use Closure;
  3. use Illuminate\Contracts\Routing\Middleware;
  4. use Illuminate\Session\TokenMismatchException;
  5. class CsrfMiddleware implements Middleware {
  6. /**
  7. * Handle an incoming request.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @param \Closure $next
  11. * @return mixed
  12. */
  13. public function handle($request, Closure $next)
  14. {
  15. if ($request->session()->token() != $request->input('_token'))
  16. {
  17. throw new TokenMismatchException;
  18. }
  19. return $next($request);
  20. }
  21. }