Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userID Module: move reading and writing of the consent string hash #6551

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,16 +590,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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding #6386 (comment)

If gdpr applies and there is no consent, here you get {userIdModules: [], hasValidated: true}, in other words, this check passes and we go ahead to write the cookie on line 255 - even though none of the userId modules will be initialized as they all failed the consent check.

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 @@ -689,17 +690,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