# Bug OP-16796 - Use correct scope for restricting custom field visibility in column selection

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-16796

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 15.5.0 |
| Observed in versions | 15.4.0 |
| Sprint | 15.5.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 15.4.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Tobias Dillmann |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

After <mention class="mention" data-id="36559" data-type="work_package" data-text="#36559">\#36559</mention> , users are no longer supposed to see custom fields of projects that they do not have access to.

However, if you have a permission of `select_custom_fields` in *any* project, you will be able to see all of the custom fields of *all* projects. This happens since the [scope chosen in that bugfix](https://github.com/opf/openproject/blob/53866a0b9f1e59359766cd7b6b1962f6c9ba2638/app/models/work_package_custom_field.rb#L41) is not the correct one.

### **Steps to reproduce:**

1.  Create a work package custom field that is not activated for all projects.

2.  Activate this custom field in only some projects

3.  Log in as a user who
    
    1.  doesn't have access to the projects in which those custom fields are activated
    
    2.  has the permission of `select_custom_fields` set (e.g. the Reader role on edge)

4.  navigate to the global work package list

5.  Open the column menu and select the custom field.

### **Actual Behavior**

The custom field can be selected as a column - even though the user is not allowed to see it (CF name could contain sensitive information).

### **Expected Behavior**

Users cannot select custom fields for projects they don't have access to, even if they have the `select_custom_fields` permission set.

<br>
