Skip to content

Commit

Permalink
move reading and writing of the consent string hash for the user id m…
Browse files Browse the repository at this point in the history
…odule to after the gdpr checks. if no user id modules will be executed, this value isn't really necessary anyways. (#6551)
  • Loading branch information
smenzer authored May 10, 2021
1 parent 701959e commit 6f732e0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,16 +592,17 @@ function refreshUserIds(options, callback) {
initializeSubmodulesAndExecuteCallbacks(function() {
let consentData = gdprDataHandler.getConsentData()

const storedConsentData = getStoredConsentData();
setStoredConsentData(consentData);

// gdpr consent with purpose one is required, otherwise exit immediately
let {userIdModules, hasValidated} = validateGdprEnforcement(submodules, consentData);
if (!hasValidated && !hasGDPRConsent(consentData)) {
utils.logWarn(`${MODULE_NAME} - gdpr permission not valid for local storage or cookies, exit module`);
return;
}

// we always want the latest consentData stored, even if we don't execute any submodules
const storedConsentData = getStoredConsentData();
setStoredConsentData(consentData);

let callbackSubmodules = [];
for (let submodule of userIdModules) {
if (submoduleNames.length > 0 &&
Expand Down Expand Up @@ -691,17 +692,17 @@ function populateSubmoduleId(submodule, consentData, storedConsentData, forceRef
* @returns {SubmoduleContainer[]} initialized submodules
*/
function initSubmodules(submodules, consentData) {
// we always want the latest consentData stored, even if we don't execute any submodules
const storedConsentData = getStoredConsentData();
setStoredConsentData(consentData);

// gdpr consent with purpose one is required, otherwise exit immediately
let { userIdModules, hasValidated } = validateGdprEnforcement(submodules, consentData);
if (!hasValidated && !hasGDPRConsent(consentData)) {
utils.logWarn(`${MODULE_NAME} - gdpr permission not valid for local storage or cookies, exit module`);
return [];
}

// we always want the latest consentData stored, even if we don't execute any submodules
const storedConsentData = getStoredConsentData();
setStoredConsentData(consentData);

return userIdModules.reduce((carry, submodule) => {
populateSubmoduleId(submodule, consentData, storedConsentData, false);
carry.push(submodule);
Expand Down

0 comments on commit 6f732e0

Please sign in to comment.