Files
nl-mall-api/app/Http/Middleware/CsrfMiddleware.php

28 lines
559 B
PHP
Raw Normal View History

2014-10-06 15:25:53 -05:00
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Session\TokenMismatchException;
class CsrfMiddleware implements Middleware {
/**
* Handle an incoming request.
*
2014-10-06 15:46:34 -05:00
* @param \Illuminate\Http\Request $request
2014-10-06 15:25:53 -05:00
* @param \Closure $next
* @throws TokenMismatchException
2014-10-06 15:46:34 -05:00
* @return mixed
2014-10-06 15:25:53 -05:00
*/
public function handle($request, Closure $next)
{
2014-10-06 15:46:34 -05:00
if ($request->session()->token() != $request->input('_token'))
2014-10-06 15:25:53 -05:00
{
throw new TokenMismatchException;
}
return $next($request);
}
}