Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset csrf meta tag based on presence of headers #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joefiorini
Copy link
Contributor

We're setting up authentication with devise and trying to just use the default session cookies. The only problem, as you probably already know, was resetting the CSRF token after sign-in/sign-out. Since we're already grabbing the token from the meta to send it up to the server, what do you think about adding the following to the csrf.js initializer template in the initializer?

This approach is based on the following stack overflow post:

http://stackoverflow.com/questions/20875591/actioncontrollerinvalidauthenticitytoken-in-registrationscontrollercreate

We're setting these headers in an after filter on a custom SessionsController that inherits from Devise::SessionsController. It would still be on the developer to send those tokens back in a header somewhere, but I think that's reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant