سؤال

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