CsrfMiddleware.php 569 B

1234567891011121314151617181920212223242526272829
  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. *
  12. * @return mixed
  13. *
  14. * @throws TokenMismatchException
  15. */
  16. public function handle($request, Closure $next)
  17. {
  18. if ($request->session()->token() != $request->input('_token'))
  19. {
  20. throw new TokenMismatchException;
  21. }
  22. return $next($request);
  23. }
  24. }