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 #956

Open
4 tasks
robertvanlienden opened this issue Jan 31, 2022 · 0 comments
Open
4 tasks

Can't add new elements; GraphQL error: Invalid CSRF token #956

robertvanlienden opened this issue Jan 31, 2022 · 0 comments

Comments

@robertvanlienden
Copy link

robertvanlienden commented Jan 31, 2022

When using https://github.com/thewebmen/silverstripe-elemental-grid I've experienced some issue where I was unable to create a new element when the CSRF token is invalid.
There is no error in the front-end notifying what's wrong, the block just doesn't get added.

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

I've first created a issue under the thewebmen/silverstripe-elemental-grid repository, but today when I was investigating this issue and I found out that this issue also occurs when I only install DNSDesign/silverstripe-elemental WITHOUT the thewebmen/silverstripe-elemental-grid extension/module.

Because of this, I assume that this issue is in this module (or maybe even in 1 of the underlying SilverStripe packages?).
After my investigation, I found out that the console error is thrown inside the following vendor file;
_resources/vendor/silverstripe/admin/client/dist/js/vendor.js.

So; The console error itself comes out of silverstripe/admin. But its triggered by adding a elemental element without a valid CSRF token...

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 to admin => select a page that uses Elemental
  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants