The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

CSRF token not working for POST method. Works for PUT

Michael's Avatar

Michael

19 Feb, 2016 11:48 PM

Hello,

I'm having difficulty getting the csrf token to work for POST methods. I am using angular and setting the csrf name and value in the request payload object. It works fine for my PUT methods, but when I use POST I am receiving a 500 server internal error with zero information other than that. I have even tried including the csrf name and value into the request header with no luck. The documentation is sort of vague on how to properly implement csrf tokens. I have tried writing a template with hidden inputs, but it does not seem to play nice with my angular/grunt setup on my localhost a.k.a does not appear probably due to the views in angular. I would appreciate any help that I can get.

General example of how I am using the tokens:

AuthService.getToken().then(function (token) { /////////////////////////GETS TOKEN NAME AND VALUE FINE
           $scope.setToken(token);
})

$scope.newStat.csrf_name = $scope.tokenName;
$scope.newStat.csrf_value = $scope.tokenVal;

CurrentStats.post($scope.newStat).then(function (data) { //////////////THIS DOES NOT WORK-500 INTERNAL SERVER ERROR
            $scope.currentStats.push(data); ///////////ALSO HAVE TRIED ADDING HIDDEN INPUT IN MAIN.HTML WITH TOKEN DATA PER EXAMPLE
            $scope.switchState();
}

selectedStat.csrf_name = $scope.tokenName;
selectedStat.csrf_value = $scope.tokenVal;
                        console.log(selectedStat);
selectedStat.put(); //////////////////THIS PUT METHOD WORKS FINE BY ATTACHING NAME AND VAL TO REQUEST OBJ

Thank you,

Michael

  1. 1 Posted by sagarkhna999 on 09 May, 2016 10:52 AM

    sagarkhna999's Avatar

    good Touch the Pen switch to look at the color slider. http://snapchattrophiess.com/snapchat-night-mode-and-flash-trophy/ the display screen with another ring finger to transition between surveillance cameras. nice.

  2. 2 Posted by dhoni on 15 Nov, 2016 07:23 AM

    dhoni's Avatar

    awesome Vidmate Apk Download: Fighting to locate a very http://vidmatedownloadz.com than its rivals like Snap Tube and Television Teammate nice.

  3. 3 Posted by Gloria on 17 Feb, 2017 06:46 AM

    Gloria 's Avatar

    awesome with exactly how you could shield your pc from the strike of http://www.wifikillpro.com/wifikill-apk-download-for-android-free-app versus the ARP spoofing strike you just have to check package nice.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac