From b9b3d875ed97be679dcd3614ab0ce118dee4b2da Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 30 Sep 2024 14:48:04 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E6=A3=80=E6=B5=8B=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8B=A5=E6=9C=89=E7=BB=84=E7=BB=87=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 2c56178ea..2ed5072a2 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -119,7 +119,7 @@ class Api::V1::UsersController < Api::V1::BaseController def check_user_can_delete org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) - org_count = Organization.where(id: org_ids).count + org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count project_count = Project.where(user_id: @observe_user.id).count render_ok({ can_delete: org_count == 0 && project_count == 0, org_count: org_count, project_count: project_count }) end @@ -128,7 +128,7 @@ class Api::V1::UsersController < Api::V1::BaseController def destroy return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(params[:password]) org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) - org_count = Organization.where(id: org_ids).count + org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count project_count = Project.where(user_id: @observe_user.id).count return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: @observe_user.id, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json, memo: params[:memo])