mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-09 22:39:50 +08:00
fixed 用户删除优化处理,多个owner时,仅将用户从组织移除, 一个时直接删除
This commit is contained in:
@@ -31,9 +31,9 @@ class Admins::UsersController < Admins::BaseController
|
||||
organizations = Organization.where(id: org_ids)
|
||||
organizations.each do |org|
|
||||
# org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)})
|
||||
org.team_users.joins(:team).where(teams: {authorize: %w(owner)})
|
||||
owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count
|
||||
# 多个owner时,仅将用户从组织移除, 一个时直接删除
|
||||
if org.count > 1
|
||||
if owner_count > 1
|
||||
org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all
|
||||
org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user