Fix Accept All button incorrectly recording rejected consent#158
Open
fvholten wants to merge 1 commit into
Open
Fix Accept All button incorrectly recording rejected consent#158fvholten wants to merge 1 commit into
fvholten wants to merge 1 commit into
Conversation
The "Accept All" button was incorrectly marking all cookie categories as rejected in the consent records instead of accepted. This occurred because the consent recording logic in updateConsentRecords() relied solely on cookie.level.includes() without proper fallback handling. Changes: - Improved category detection logic with fallback between cookie.categories and cookie.level - Added more robust consent recording that works regardless of cookie data structure - Ensures all categories are properly recorded as accepted when "Accept All" is clicked Fixes the issue where consent records showed all categories as false instead of true when users clicked "Accept All". 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical bug where the "Accept All" button was incorrectly marking all cookie categories as rejected in the consent records instead of accepted.
Problem Description
When users clicked the "Accept All" button on the cookie consent modal, the consent would be processed correctly (cookies would be allowed), but the consent records stored in the database would incorrectly show all cookie categories (necessary, analytics, targeting, preferences) as
falseinstead oftrue.Root Cause Analysis
The issue was in the
updateConsentRecordsfunction insrc/client/index.js(lines 215-218). The function was using a fragile approach to determine accepted categories:This logic failed to properly detect accepted categories when the "Accept All" functionality was triggered.
Solution
Improved the consent recording logic with a more robust approach:
Changes Made
cookie.categoriesandcookie.levelwith proper fallback logicTesting
true)Impact
This fix ensures that consent records accurately reflect user choices, which is critical for legal compliance and data governance.
🤖 Generated with Claude Code