summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-23 13:36:43 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-23 13:36:43 +0000
commitb51fe6831123830f729295e16bd5aa99e3012c57 (patch)
treed3e3ece613ba01b7604d8ce6e7ae420e722af6f9 /app
parent1cfdc7a63b2ebeffdd6f44310f42c83b78a6e7e6 (diff)
parente80d7a804f335447c8c4db8d8de3532957d80ec8 (diff)
downloadgitlab-ce-b51fe6831123830f729295e16bd5aa99e3012c57.tar.gz
Merge branch 'fix-delete-user-error' into 'master'
Fix error when deleting a user who has projects ### What does this MR do? This MR fixes an error that prevented users from being deleted in the Admin page if the user had personal projects. ### Why was this MR needed? Deleting a user who had projects would result in an error such as this: ``` Started DELETE "/admin/users/tdb1" for MYIP at 2015-06-22 20:53:02 +0100 Processing by Admin::UsersController#destroy as HTML Parameters: {"authenticity_token"=>"[FILTERED]", "id"=>"tdb1"} Completed 500 Internal Server Error in 30ms (ActiveRecord: 6.7ms) NameError (undefined local variable or method `current_user' for #<DeleteUserService:0x0000000cd01d38>): app/services/delete_user_service.rb:10:in `block in execute' app/services/delete_user_service.rb:7:in `execute' app/controllers/admin/users_controller.rb:89:in `destroy' ``` ### What are the relevant issue numbers? * Closes #1856 * Closes https://github.com/gitlabhq/gitlabhq/issues/9394 See merge request !868
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/users_controller.rb2
-rw-r--r--app/controllers/registrations_controller.rb2
-rw-r--r--app/services/delete_user_service.rb6
3 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 06d6d61e907..2bc236871b0 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -86,7 +86,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def destroy
- DeleteUserService.new.execute(user)
+ DeleteUserService.new(current_user).execute(user)
respond_to do |format|
format.html { redirect_to admin_users_path }
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 6ccc7934f2f..3b3dc86cb68 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -6,7 +6,7 @@ class RegistrationsController < Devise::RegistrationsController
end
def destroy
- DeleteUserService.new.execute(current_user)
+ DeleteUserService.new(current_user).execute(current_user)
respond_to do |format|
format.html { redirect_to new_user_session_path, notice: "Account successfully removed." }
diff --git a/app/services/delete_user_service.rb b/app/services/delete_user_service.rb
index 9017a63af3b..e622fd5ea5d 100644
--- a/app/services/delete_user_service.rb
+++ b/app/services/delete_user_service.rb
@@ -1,4 +1,10 @@
class DeleteUserService
+ attr_accessor :current_user
+
+ def initialize(current_user)
+ @current_user = current_user
+ end
+
def execute(user)
if user.solo_owned_groups.present?
user.errors[:base] << 'You must transfer ownership or delete groups before you can remove user'