Project

General

Profile

Actions

Defect #42106

open

Member roles are incorrectly added when a user's memberships are updated

Added by Thomas Löber 4 days ago. Updated 41 minutes ago.

Status:
Confirmed
Priority:
Normal
Assignee:
Category:
Permissions and roles
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Member roles are incorrectly added when a user's memberships are updated on the user's Projects tab.

Setup:
  • 2 Roles: R1 and R2
  • 2 Groups: G1 and G2
  • G1 has role R1
  • G2 has roles R1 and R2
  • User is in groups G1 and G2
    ➔ that means the user has two inherited roles: R1 inherited by G1 and G2, and R2 inherited by G2
Steps to reproduce:
  • On the user's Projects tab click on Edit and then on Save without changing any checkboxes
  • Remove the user from G1 and G2

Expected result: The user no longer has any roles.

Actual result: The user still has the role R1.

Reason: When the user's memberships are saved, any roles inherited by more than one group are added as non-inherited roles.

Solution: Fix Member#role_ids=:

   def role_ids=(arg)
     ids = (arg || []).collect(&:to_i) - [0]
     # Keep inherited roles
-    ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
+    ids |= member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)

Files

add_test.diff (1.95 KB) add_test.diff Mizuki ISHIKAWA, 2025-01-17 07:06
Actions

Also available in: Atom PDF