get csrf token from /dev/csrf not /register

This commit is contained in:
Hayden Faulds 2017-12-01 16:47:38 +00:00
parent b51ee7ea7e
commit 938d22da3f

View file

@ -161,13 +161,10 @@ class User
getCsrfToken: (callback = (error) ->) ->
@request.get {
url: "/register"
url: "/dev/csrf"
}, (err, response, body) =>
return callback(err) if err?
csrfMatches = body.match("window.csrfToken = \"(.*?)\";")
if !csrfMatches?
return callback(new Error("no csrf token found"))
@csrfToken = csrfMatches[1]
@csrfToken = body
@request = @request.defaults({
headers:
"x-csrf-token": @csrfToken