Commit 888e493b82435a074938aa25f823c2c9b0fb8026
1 parent
31fdcac1
Exists in
master
and in
4 other branches
Update membership instead of remove/add if it permissions were changed
Showing
1 changed file
with
10 additions
and
4 deletions
Show diff stats
lib/gitlab/user_team_manager.rb
... | ... | @@ -80,12 +80,18 @@ module Gitlab |
80 | 80 | |
81 | 81 | def update_team_user_access_in_project(team, user, project, action) |
82 | 82 | granted_access = max_teams_member_permission_in_project(user, project, action) |
83 | - | |
84 | 83 | project_team_user = UsersProject.find_by_user_id_and_project_id(user.id, project.id) |
85 | - project_team_user.destroy if project_team_user.present? | |
86 | 84 | |
87 | - # project_team_user.project_access != granted_access | |
88 | - project.team << [user, granted_access] if granted_access > 0 | |
85 | + if granted_access.zero? | |
86 | + project_team_user.destroy if project_team_user.present? | |
87 | + return | |
88 | + end | |
89 | + | |
90 | + if project_team_user.present? | |
91 | + project_team_user.update_attributes(project_access: granted_access) | |
92 | + else | |
93 | + project.team << [user, granted_access] | |
94 | + end | |
89 | 95 | end |
90 | 96 | |
91 | 97 | def max_teams_member_permission_in_project(user, project, action = nil, teams = nil) | ... | ... |