Open Closed

Gdpr Module Always Shows The Consent Even It is accepted #5957


User avatar
0
cangunaydin created
  • ABP Framework version: v7.4.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)

Hello, I recently upgraded my abp version from 7.3.2 to 7.4.0, I don't know if this is related with upgrade, maybe this wasn't working fine before.

In angular part of the gdpr module, when i look at the source code, it checks the cookie consent, if it is true it doesn't show the accept cookie bar as I understand.

here is the code for checking the cookie, here cookie key is '.AspNet.Consent'

 protected checkCookieConsent() {
    const hasCookieConsent =
      decodeURIComponent(this.document.cookie)
        .split(' ')
        .indexOf(this.cookieKey + '=true') > -1;

    if (hasCookieConsent) {
      this.showCookieConsent = false;
    }
  }

When i look at my cookies on chrome,I can see that it is true.

when i debug this, i can see that array from the code decodeURIComponent(this.document.cookie.split(' ') has an item like

here you can see indexOf shouldn't be .indexOf(this.cookieKey + '=true') but it should be .indexOf(this.cookieKey + '=true;') to make it work (';' semicolon at the end). I use chrome by the way. Maybe it works with other browsers, i didn't test it with others. Is there any trick that I can do to fix it fast?


1 Answer(s)
  • User Avatar
    0
    masum.ulu created
    Support Team Angular Expert

    Hi Can,

    I've reproduced your case, you right it should also check with ; semicolon at the end. But when the app opening first time at the cookies, only have 2 item. That's why we should also check for without ; I've updated code as below

    protected checkCookieConsent() {
      const decodedCookies = decodeURIComponent(this.document.cookie);
      this.showCookieConsent = !decodedCookies.includes(`${this.cookieKey}=true`);
    }
    

    It'll solve problem at 7.4.1 I've refunded your credit

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09