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

Can't add new elements, GraphQL error: Invalid CSRF token #3

Open
3 tasks
robertvanlienden opened this issue Jan 10, 2022 · 1 comment
Open
3 tasks
Labels

Comments

@robertvanlienden
Copy link
Contributor

robertvanlienden commented Jan 10, 2022

This weekend I've encountered some issue when I was trying to add a new element.

I've created a new Grid page, and tried to add a new element.
Then just nothing happens.

After some little investigation I've found a error in the console;
GraphQL error: Invalid CSRF token

Seems like we need to catch this error and show something on the front-end like;
"Session expired! Please refresh the page".

Right now I'm not 100% sure if this issue only occurs in our Elemental Grid, or also on the DNADesign/silverstripe-elemental package without our Elemental Grid.
After some investigation, I found out that the console error is thrown inside the following vendor file;
_resources/vendor/silverstripe/admin/client/dist/js/vendor.js

Reproduction steps

For security reasons, CSRF token will get invalidate when you open dev tools (F12) and view the admin in responsive.
So this makes it relative easy to reproduce the issue;

  • Go t admin => select a grid page
  • F12 (dev tools) => Toggle device toolbar (responsive view)
  • Add a new row/grid block and see that it won't get added. Now, the error shows up in the console
@robertvanlienden
Copy link
Contributor Author

Investigated => Found out that this issue also occurs when only using DNADesign/silverstripe-elemental (without grid module)

Created silverstripe/silverstripe-elemental#956 as bug-report to the original module.

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

No branches or pull requests

1 participant