Frage

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.

War es hilfreich?

Lösung

You have a typo:

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

It should be:

Route::group(array('before' => 'csrf'), function() {
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top