]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4411 Deactivate users instead of deleting them
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Wed, 26 Jun 2013 07:46:36 +0000 (09:46 +0200)
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Wed, 26 Jun 2013 07:46:48 +0000 (09:46 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/users_controller.rb

index 4f9a1cf304cce1a1a5c9e693cc0828346e55d097..16d19f4d1addb7435c2fb6130035462885b7eea4 100644 (file)
@@ -74,7 +74,7 @@ class Api::UsersController < Api::ApiController
       render_bad_request('An active user with this login already exists')
     else
       if user
-        user.update_attributes!(params)
+        user.reactivate!(java_facade.getSettings().getString('sonar.defaultGroup'))
         user.notify_creation_handlers
       else
         user = prepare_user
@@ -139,14 +139,14 @@ class Api::UsersController < Api::ApiController
     access_denied unless has_role?(:admin)
     require_parameters :login
 
-    user = User.find_active_by_login(params[:login])
+    @user = User.find_active_by_login(params[:login])
 
-    if user.nil?
+    if @user.nil?
       render_bad_request "Could not find user with login #{params[:login]}"
-    elsif user == current_user || user.login == 'admin'
+    elsif @user == current_user || @user.login == 'admin'
       render_bad_request "Cannot delete user #{params[:login]}"
     else
-      if user.destroy
+      if @user.deactivate
         render_success "Successfully deleted user #{params[:login]}"
       else
         render_error("Could not delete user #{params[:login]}")