CsrfFilter.php 551 B

1234567891011121314151617181920212223242526
  1. <?php namespace App\Http\Filters;
  2. use Illuminate\Http\Request;
  3. use Illuminate\Routing\Route;
  4. use Illuminate\Session\TokenMismatchException;
  5. class CsrfFilter {
  6. /**
  7. * Run the request filter.
  8. *
  9. * @param \Illuminate\Routing\Route $route
  10. * @param \Illuminate\Http\Request $request
  11. * @return void
  12. *
  13. * @throws \Illuminate\Session\TokenMismatchException
  14. */
  15. public function filter(Route $route, Request $request)
  16. {
  17. if ($request->getSession()->token() != $request->input('_token'))
  18. {
  19. throw new TokenMismatchException;
  20. }
  21. }
  22. }