Regenerate and pull new CSRF token via AJAX and Rails

I have a Backbone app on top of a Rails backend. I have no problem sending the CSRF token, but I have a problem when I log out and want to log back in, but this does not validate the login because the CSRF token changes after I log out.

Is there a way to pull this CSRF token without making a full page request, or should I always force the browser to refresh the entire page from the server after logging out to prevent this from happening?

I'm fine with a full browser refresh if there is no other way around this CSRF issue, I just think my users are getting a kind of shitty experience due to CSRF, but I think they will forgive me if their accounting is better protected.

+3


source to share


1 answer


Check out the tutorial "Finally Dealing Correctly with CSRF Rails Protection and Backbone AJAX" here: http://blog.softr.li/post/43146401263/finally-correctly-dealing-with-rails-csrf-protection



+1


source







All Articles