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

CSRF mismatch when sails restarted #25

Open
shopapps opened this issue Aug 3, 2015 · 3 comments
Open

CSRF mismatch when sails restarted #25

shopapps opened this issue Aug 3, 2015 · 3 comments

Comments

@shopapps
Copy link

shopapps commented Aug 3, 2015

Hi,

Is there an easy way for me to fix the issue where if I restart my sails server, then the Ember App reconnects the socket ok, however it does not refresh the CSRF token and so when i try and save a record I get an error Code 403 - CSRF mismatch from the sails server.

I tried inserting

this.set('csrfToken', false);

into line 380 of services/sails-socket.js but it did not seem to help me.. anyone else come across this issue before?

thanks.

Paul.

@shopapps
Copy link
Author

Has anyone else experienced this or found a workaround at all? - thanks.

@huafu
Copy link
Owner

huafu commented Oct 2, 2015

As a workaround until I have time to work on this, you can call adapter.fetchCSRFToken(true) which is a promise.

(pm: sorry to answer that late, so so busy lately)

@shopapps
Copy link
Author

shopapps commented Oct 2, 2015

That's no problem, thanks for your help.

Actually as an FYI, I did some more googling and discovered that by changing the session store in my sailsjs api (from internal memory to mongo in my case, but I assume redis would be the same), then the client side stored CSRF token is still 'valid' after a restart of the API.

So this masks/resolves the issue for me, but am still not sure if its a ember-data-sails problem or a sailsjs configuration issue.

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

No branches or pull requests

2 participants