mollie / Shopware6

MIT License
51 stars 53 forks source link

Subscriptions: Forms should support csrf.mode: ajax #419

Closed michnhokn closed 2 years ago

michnhokn commented 2 years ago

Currently using the mollie plugin with csrf.mode: ajax breaks the async actions from the account.

An unsubscribe or change of the sipping address is then no longer possible.

The fix for this problem is the mode ajax for CSRF tokens. In this mode Shopware is fetching a token using a XML HTTP request before sending a POST request. Enabling this behavior in our plugins is quite easy. If you're dealing with a form element, simply add the JS plugin data-form-csrf-handler="true" to it and you're good to go.

If you're fetching data using a POST request in your JavaScript, please use the method fetchCsrfToken from the HTTP client to fetch a token before sending the actual request:

this.client.fetchCsrfToken((token) => {
   // console.log(token);
})
boxblinkracer commented 2 years ago

Hi sry for the long delay

that totally makes sense ill make sure its developed

thanks for this

boxblinkracer commented 2 years ago

released in v3.2.0