summaryrefslogtreecommitdiffstats
path: root/app/controllers/auth_sources_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-13 15:04:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-13 15:04:11 +0000
commit7775f86a69f187b8e162280e1f4de1a8b58fd3dd (patch)
tree11d193dc381eb6c006d917ccf54439d81dde1de9 /app/controllers/auth_sources_controller.rb
parentc31f498ba6a21fd3e5ce7b9ba2f3b3cdc1b2e05b (diff)
downloadredmine-7775f86a69f187b8e162280e1f4de1a8b58fd3dd.tar.gz
redmine-7775f86a69f187b8e162280e1f4de1a8b58fd3dd.zip
Code cleanup in AuthSource controller and views.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10996 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/auth_sources_controller.rb')
-rw-r--r--app/controllers/auth_sources_controller.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/controllers/auth_sources_controller.rb b/app/controllers/auth_sources_controller.rb
index 0ba89ec02..ede9e0733 100644
--- a/app/controllers/auth_sources_controller.rb
+++ b/app/controllers/auth_sources_controller.rb
@@ -20,6 +20,7 @@ class AuthSourcesController < ApplicationController
menu_item :ldap_authentication
before_filter :require_admin
+ before_filter :find_auth_source, :only => [:edit, :update, :test_connection, :destroy]
def index
@auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 10
@@ -28,6 +29,7 @@ class AuthSourcesController < ApplicationController
def new
klass_name = params[:type] || 'AuthSourceLdap'
@auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source])
+ render_404 unless @auth_source
end
def create
@@ -41,11 +43,9 @@ class AuthSourcesController < ApplicationController
end
def edit
- @auth_source = AuthSource.find(params[:id])
end
def update
- @auth_source = AuthSource.find(params[:id])
if @auth_source.update_attributes(params[:auth_source])
flash[:notice] = l(:notice_successful_update)
redirect_to auth_sources_path
@@ -55,7 +55,6 @@ class AuthSourcesController < ApplicationController
end
def test_connection
- @auth_source = AuthSource.find(params[:id])
begin
@auth_source.test_connection
flash[:notice] = l(:notice_successful_connection)
@@ -66,11 +65,18 @@ class AuthSourcesController < ApplicationController
end
def destroy
- @auth_source = AuthSource.find(params[:id])
unless @auth_source.users.exists?
@auth_source.destroy
flash[:notice] = l(:notice_successful_delete)
end
redirect_to auth_sources_path
end
+
+ private
+
+ def find_auth_source
+ @auth_source = AuthSource.find(params[:id])
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
end