For some reason the CSRF is not working, is not redirecting:

here is the filter

Route::filter('csrf', function()
{

    if (Session::token() != Input::get('_token')) { 

        return Redirect::to('/')->with('errors', 'request failed!');

    }

});

And Here is my route

Route::group(array('before' => 'crsf'), function() {

    Route::get("/Token", function() {

        $different = (Session::token() != Input::get('_token')) ? "IS DIFFERENT" : "IS EQUAL";

        $token = Session::token();
        $input = Input::get("_token");

        $equals = ($token == $input) ? "TRUE" : "FALSE";

        return Response::json(array(
                    "session_token" => $token,
                    "input"     => $input,
                    "diff"      => $different,
                    "equals"    => $equals
       ));

   });

});

The Response shows that the result of the comparison between the Session token and the Input (which is NULL) is FALSE, they are different but the filter is not redirecting.

有帮助吗?

解决方案

You have a typo:

Route::group(array('before' => 'crsf'), function() {

It should be:

Route::group(array('before' => 'csrf'), function() {
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top