elleracompany / craft-cookie-consent

GDPR-Compliant cookie consent banner for Craft CMS
Other
6 stars 6 forks source link

Shows a blank page with "true" #56

Closed intositeme closed 3 years ago

intositeme commented 3 years ago

The cookie gets save after accepting. But when refreshed, just shows a blank page with "true".

jellingsen commented 3 years ago

Could you provide some more information on this? What version of craft, the plugin and PHP are you running. What do you mean by "refreshed", your front page is blank with "true" on it?

nordentwickler commented 3 years ago

I can confirm this - php 7.4, Craft 3.5.17, latest craft-cookie-consent.

After submitting the consent form with any of its button (in fact, a html button would be much better than inputs as default), a blank page with the word "string" is loaded.

If you just "return" in Consent Controller and not "return true" in line 52, it works.

jellingsen commented 3 years ago

Omitting the return true, or only using return, results in the Javascript getting a 404 from Craft (Even tho the consents are saved updated).

I'm not able to reproduce this issue, and as there is nothing in the javascript file that should redirect the browser to the consent endpoint. Are you using a custom template and/or custom javascript?

I've updated the input links to buttons.

SandraSundqvist commented 3 years ago

Hi,

We faced the same issue when using a custom template and accidentally removed the "Accept selected"-button but used the other "Accept all"-button with the id="elc-accept-all-link",

So this didn't work (returned a blank page with "true" after clicking the button):

<input id="elc-accept-all-link" type="submit" value="{{ "Accept all"|t}}">

But this did:

<input id="elc-accept-link" type="submit" value="{{ "Accept selected"|t }}">
<input id="elc-accept-all-link" type="submit" value="{{ "Accept all"|t}}">

Hope this helps.

jellingsen commented 3 years ago

After some digging i think i found the issue that you were facing. When creating a custom template, you probably omitted some buttons that you did not intend to use in the template. This caused the javascript execution to fail when trying to attach an event listener to a object that did not exist.

Consequently, the click on a button was treated like a regular form submit, and the request was not sent over XHR.

I've update the plugin to skip trying to attach events when the element is null. Update to v1.6.1 and you should be good.