Skip to content

Commit

Permalink
Gdpr vendor exceptions (prebid#5201)
Browse files Browse the repository at this point in the history
* vendorExceptions is a global check

* two allowed vars not one duh
  • Loading branch information
robertrmartinez authored and Jimmy Tu committed Jun 12, 2020
1 parent 71fefd9 commit 5b790ff
Showing 1 changed file with 8 additions and 42 deletions.
50 changes: 8 additions & 42 deletions modules/gdprEnforcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,15 @@ function getGvlid() {
* @returns {boolean}
*/
function validateRules(rule, consentData, currentModule, gvlid) {
let isAllowed = false;
if (!rule.vendorExceptions) rule.vendorExceptions = [];
if (rule.enforcePurpose && rule.enforceVendor) {
if (
includes(rule.vendorExceptions, currentModule) ||
(
utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true &&
utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true
)
) {
isAllowed = true;
}
} else if (rule.enforcePurpose === false && rule.enforceVendor === true) {
if (
includes(rule.vendorExceptions, currentModule) ||
(
utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true
)
) {
isAllowed = true;
}
} else if (rule.enforcePurpose === false && rule.enforceVendor === false) {
if (
!includes(rule.vendorExceptions, currentModule) ||
(
(utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true) &&
(utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true)
)
) {
isAllowed = true;
}
} else if (rule.enforcePurpose === true && rule.enforceVendor === false) {
if (
(utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true) &&
(
!includes(rule.vendorExceptions, currentModule) ||
(utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true)
)
) {
isAllowed = true;
}
// if vendor has exception => always true
if (includes(rule.vendorExceptions || [], currentModule)) {
return true;
}
return isAllowed;
// if enforcePurpose is false or purpose was granted isAllowed is true, otherwise false
const purposeAllowed = rule.enforcePurpose === false || utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true;
// if enforceVendor is false or vendor was granted isAllowed is true, otherwise false
const vendorAllowed = rule.enforceVendor === false || utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true;
return purposeAllowed && vendorAllowed;
}

/**
Expand Down

0 comments on commit 5b790ff

Please sign in to comment.