CsrfMiddleware.php 559 B

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