diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-09-08 10:47:16 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-09-08 10:49:29 +0200 |
commit | 0b2dc25454d3892077fca7cee646228b2ce8b3f6 (patch) | |
tree | 9caacbe2638cb7d7e1deb3770dedbb5ae7d577be /sonar-server | |
parent | d80f27ec08d7517b735c5877b5360300ba6da496 (diff) | |
download | sonarqube-0b2dc25454d3892077fca7cee646228b2ce8b3f6.tar.gz sonarqube-0b2dc25454d3892077fca7cee646228b2ce8b3f6.zip |
SONAR-2412 improve checks
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb | 19 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb | 2 |
2 files changed, 10 insertions, 11 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb index df88dda1cd3..fc93e0f224c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb @@ -56,16 +56,15 @@ class Api::ProjectsController < Api::ApiController # curl -X DELETE http://localhost:9000/api/projects/<key> -v -u admin:admin # def destroy - begin - if params[:id].present? - project = Project.by_key(params[:id]) - Project.delete_project(project) - end - render_success("Project deleted") - rescue Exception => e - logger.error("Fails to execute #{request.url} : #{e.message}") - render_error(e.message, 500) - end + bad_request("Missing project key") unless params[:id].present? + + project = Project.by_key(params[:id]) + bad_request("Not valid project") unless project + access_denied unless is_admin?(project) + bad_request("Not valid project") unless project.project? + + Project.delete_project(project) + render_success("Project deleted") end private diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 29fc5cab8f7..4ecfd32f937 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -40,7 +40,7 @@ class ProjectController < ApplicationController def delete if params[:id] @project = Project.by_key(params[:id]) - if @project && is_admin?(@project) + if @project && @project.project? && is_admin?(@project) Project.delete_project(@project) end end |