From a0ee87cbd59b3ca6cc2ef3280b13d43d01343c6f Mon Sep 17 00:00:00 2001 From: Adithya Kumar Date: Tue, 7 Sep 2021 19:33:25 +0530 Subject: [PATCH] Update code for making Jquery and XSRF play nicely --- servant-auth-server/README.lhs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/servant-auth-server/README.lhs b/servant-auth-server/README.lhs index 9dba4ac..5825318 100644 --- a/servant-auth-server/README.lhs +++ b/servant-auth-server/README.lhs @@ -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()); +}); ~~~