# Bug SPAR-154 - Possible to create, update and delete relations to work package for which user does not have permission to manage relations

Project: Stream Planning and Reporting
Status: closed
URL: https://community.openproject.org/work_packages/SPAR-154

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | High |
| Module | Modules and project features / Relations and scheduling |
| Target versions | 16.5.0 |
| Observed in versions | 15.2.0 |
| Bug found in version (deprecated) | 15.2.x |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Mir Bhatia |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

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

## Costs

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

## Description

### \\Steps to reproduce

**Common steps:**

1.  Be a non admin user
    
2.  Have two projects
    
    1.  &quot;Project read only&quot;: The user is member in here but does not have the &quot;Manage work package relations&quot; permission
        
    2.  &quot;Project writable&quot;: The user is member with the permission &quot;Manage work package relations&quot; permission
        
3.  Have two work packages one in each project
    
    1.  &quot;Work package read only&quot;
        
    2.  &quot;Work package writable&quot;
        
4.  Go to the writable ticket &quot;Work package writable&quot;
    

**Create case:**

1.  Go to the relations tab and open the modal to create a new &quot;Blocks&quot; permission (Also possible for other relations)
    
2.  Insert &quot;Work package read only&quot;
    
3.  Click &quot;Add&quot;
    

**Update case (If there already is an existing relation):**

1.  Go to the relations tab and click on the three dots menu for the relation to the read only WP
    
2.  Click &quot;Edit relation&quot;
    
3.  Update the description
    
4.  Click &quot;Save&quot;
    

**Delete case (If there already is an existing relation):**

1.  Go to the relations tab and click on the three dots menu for the relation to the read only WP
    
2.  Click &quot;Delete relation&quot;
    

### What is the buggy behavior?

**Create case:**

*   The relation is created.
    

**Update case (If there already is an existing relation):**

*   The relation is updated.
    

**Delete case (If there already is an existing relation):**

*   The relation is deleted.
    

### What is the expected behavior?

**Common:**

*   We enforce symmetry; the user needs write permission on both work packages in order to be able to create the relation.
    

**Add case (in-line error):**

*   Relations with read-only permissions are still visible in the results. However, selecting one in the create realtion dialog form throws an in-line error below the field with text:
    
    *   &quot;The selected work package cannot be added because you do not have edit permissions for the selected work package.&quot;
        

**Update case (flash error)**

*   Show error after click on &quot;Edit relations&quot; in the more menu (before displaying the dialog) a relation already exists
    
    *   &quot;This relation cannot be edited because you do not have edit permissions for the selected work package.&quot;
        

**Delete case (flash error):**

*   Show error after click on &quot;Delete relations&quot; in the More menu:
    
    *   &quot;This relation cannot be deleted because you do not have edit permissions for the selected work package.&quot;
        
    
    <br>
    

### Screenshots and other files

<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/314824/content">

### Technical notes

This is possible because the `relations/base_contract.rb` only checks the `model.from` work package for the permission.
