Commit 65455278 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve user block logic

When block user - remove it from joined groups
Dont remove user from own resources (groups, users)
parent 0787726a
...@@ -126,6 +126,17 @@ class User < ActiveRecord::Base ...@@ -126,6 +126,17 @@ class User < ActiveRecord::Base
after_transition any => :blocked do |user, transition| after_transition any => :blocked do |user, transition|
# Remove user from all projects and # Remove user from all projects and
user.users_projects.find_each do |membership| user.users_projects.find_each do |membership|
# skip owned resources
next if membership.project.owner == user
return false unless membership.destroy
end
# Remove user from all groups
user.users_groups.find_each do |membership|
# skip owned resources
next if membership.group.owner == user
return false unless membership.destroy return false unless membership.destroy
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment