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

Fix .allowedCategory() when mode is set to opt-out #178

Merged
merged 2 commits into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exemptLabels:
- low-priority
- documentation
# Label to use when marking an issue as stale
staleLabel: wontfix
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
Expand Down
11 changes: 7 additions & 4 deletions src/cookieconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,10 +1438,13 @@
* @returns {boolean}
*/
_cookieconsent.allowedCategory = function(cookie_category){
return _inArray(
JSON.parse(_getCookie(_config.cookie_name, 'one', true) || '{}')['level'] || [] ,
cookie_category
) > -1;

if(cookie_consent_accepted || _config.mode === 'opt-in')
var allowed_categories = JSON.parse(_getCookie(_config.cookie_name, 'one', true) || '{}')['level'] || []
else // mode is 'opt-out'
var allowed_categories = default_enabled_categories;

return _inArray(allowed_categories, cookie_category) > -1;
}

/**
Expand Down