Created
March 17, 2015 02:37
-
-
Save shin1x1/e979bf76c305513c7089 to your computer and use it in GitHub Desktop.
CSRF Protection Filter for Laravel 4 with AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::filter( | |
'csrf', | |
function () { | |
$token = Request::header('X-XSRF-TOKEN'); | |
if (empty($token)) { | |
$token = Input::get('_token'); | |
} | |
if (Session::token() !== $token) { | |
throw new Illuminate\Session\TokenMismatchException; | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment