allow segment access to be AND as well as OR

Created on 12 July 2023, almost 2 years ago
Updated 27 January 2025, 3 months ago

Problem/Motivation

The code in unomi_check_access() returns an allowed access result as soon as one segment matches:

    // Go over each segment that is allowed to see this paragraph.
    foreach ($segments as $segment) {
      $segmentValue = isset($segment['value']) ? $segment['value'] : '';
      foreach ($cookieValues as $cookieValue) {
        // Check cookie.
        if ($cookieValue === (string) $segmentValue) {
          return AccessResult::allowed()
            ->addCacheableDependency($entity)
            ->addCacheContexts(['cookies:' . $cookieManager->getCookieName()]);
        }
      }
    }

It would be useful to allow this to be ANDed as well. This would work better with more granular segments.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024