Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Update code for making Jquery and XSRF play nicely #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions servant-auth-server/README.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,14 @@ reading the cookie. For jQuery, and with the default values, that might be:

~~~ javascript

var token = (function() {
var getXSRFToken = function() {
r = document.cookie.match(new RegExp('XSRF-TOKEN=([^;]+)'))
if (r) return r[1];
})();

};

$.ajaxPrefilter(function(opts, origOpts, xhr) {
xhr.setRequestHeader('X-XSRF-TOKEN', token);
}
xhr.setRequestHeader('X-XSRF-TOKEN', getXSRFToken());
});

~~~

Expand Down