Skip to content

Commit

Permalink
Merge pull request #49 from mickr/BIG-21501
Browse files Browse the repository at this point in the history
BIG-21501 - EU Cookie warning
  • Loading branch information
Mick Ryan committed Dec 18, 2015
2 parents fb1c282 + eeaa4a0 commit 962f2c1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/api/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default class extends Base
*/
privacyNotificationCheck() {
const alreadyAcceptedCookies = document.cookie.indexOf('ACCEPT_COOKIE_USAGE') !== -1;
let cookieStr;

if (alreadyAcceptedCookies) {
return;
}
Expand All @@ -31,7 +33,7 @@ export default class extends Base
const date = new Date();
const event = {
defaultPrevented: false,
preventDefault: function() {
preventDefault() {
this.defaultPrevented = true;
},
};
Expand All @@ -41,12 +43,16 @@ export default class extends Base
}

date.setDate(date.getDate() + 365);

document.cookie = `ACCEPT_COOKIE_USAGE=1;expires=${date.toGMTString()}; path=/`;

cookieStr = `ACCEPT_COOKIE_USAGE=1;expires=${date.toGMTString()}; path=/`;
Hooks.emit('cookie-privacy-notification', event, response.data.PrivacyCookieNotification);

if (!event.defaultPrevented) {
// Set up handler to listen if the cookie was accepted.
if (event.defaultPrevented) {
Hooks.on('cookie-privacy-accepted', () => {
document.cookie = cookieStr;
});
} else {
document.cookie = cookieStr;
alert(response.data.PrivacyCookieNotification);
}
}
Expand Down

0 comments on commit 962f2c1

Please sign in to comment.