문제

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