summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-11 11:43:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-11 11:43:27 +0000
commitbd47af098fefef968647f7634105b22eb115d4b2 (patch)
tree8ff70b22d6baf6925bfe81a6242d2a91b1411b9b /app
parent81185a8d93c049eb77d3c3638dc01ab4e3a65f07 (diff)
downloadredmine-bd47af098fefef968647f7634105b22eb115d4b2.tar.gz
redmine-bd47af098fefef968647f7634105b22eb115d4b2.zip
Merged LdapAuthSourceController into AuthSourceController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9232 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/auth_sources_controller.rb25
-rw-r--r--app/controllers/ldap_auth_sources_controller.rb26
-rw-r--r--app/helpers/auth_sources_helper.rb3
-rw-r--r--app/models/auth_source.rb1
-rw-r--r--app/views/auth_sources/_form_auth_source_ldap.html.erb (renamed from app/views/ldap_auth_sources/_form.html.erb)0
-rw-r--r--app/views/auth_sources/edit.html.erb3
-rw-r--r--app/views/auth_sources/new.html.erb3
7 files changed, 16 insertions, 45 deletions
diff --git a/app/controllers/auth_sources_controller.rb b/app/controllers/auth_sources_controller.rb
index b1150bf71..7a382eb43 100644
--- a/app/controllers/auth_sources_controller.rb
+++ b/app/controllers/auth_sources_controller.rb
@@ -17,32 +17,31 @@
class AuthSourcesController < ApplicationController
layout 'admin'
+ menu_item :ldap_authentication
before_filter :require_admin
def index
- @auth_source_pages, @auth_sources = paginate auth_source_class.name.tableize, :per_page => 10
- render "auth_sources/index"
+ @auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 10
end
def new
- @auth_source = auth_source_class.new
- render 'auth_sources/new'
+ klass_name = params[:type] || 'AuthSourceLdap'
+ @auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source])
end
def create
- @auth_source = auth_source_class.new(params[:auth_source])
+ @auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source])
if @auth_source.save
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index'
else
- render 'auth_sources/new'
+ render :action => 'new'
end
end
def edit
@auth_source = AuthSource.find(params[:id])
- render 'auth_sources/edit'
end
def update
@@ -51,14 +50,14 @@ class AuthSourcesController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index'
else
- render 'auth_sources/edit'
+ render :action => 'edit'
end
end
def test_connection
- @auth_method = AuthSource.find(params[:id])
+ @auth_source = AuthSource.find(params[:id])
begin
- @auth_method.test_connection
+ @auth_source.test_connection
flash[:notice] = l(:notice_successful_connection)
rescue Exception => e
flash[:error] = l(:error_unable_to_connect, e.message)
@@ -74,10 +73,4 @@ class AuthSourcesController < ApplicationController
end
redirect_to :action => 'index'
end
-
- protected
-
- def auth_source_class
- AuthSource
- end
end
diff --git a/app/controllers/ldap_auth_sources_controller.rb b/app/controllers/ldap_auth_sources_controller.rb
deleted file mode 100644
index 29f1bc3d7..000000000
--- a/app/controllers/ldap_auth_sources_controller.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2011 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-class LdapAuthSourcesController < AuthSourcesController
- menu_item :ldap_authentication
-
- protected
-
- def auth_source_class
- AuthSourceLdap
- end
-end
diff --git a/app/helpers/auth_sources_helper.rb b/app/helpers/auth_sources_helper.rb
index bd4bca87e..8ef17b209 100644
--- a/app/helpers/auth_sources_helper.rb
+++ b/app/helpers/auth_sources_helper.rb
@@ -18,4 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module AuthSourcesHelper
+ def auth_source_partial_name(auth_source)
+ "form_#{auth_source.class.name.underscore}"
+ end
end
diff --git a/app/models/auth_source.rb b/app/models/auth_source.rb
index 933be904a..63799f5cf 100644
--- a/app/models/auth_source.rb
+++ b/app/models/auth_source.rb
@@ -20,6 +20,7 @@
class AuthSourceException < Exception; end
class AuthSource < ActiveRecord::Base
+ include Redmine::SubclassFactory
include Redmine::Ciphering
has_many :users
diff --git a/app/views/ldap_auth_sources/_form.html.erb b/app/views/auth_sources/_form_auth_source_ldap.html.erb
index 3ddf43a9a..3ddf43a9a 100644
--- a/app/views/ldap_auth_sources/_form.html.erb
+++ b/app/views/auth_sources/_form_auth_source_ldap.html.erb
diff --git a/app/views/auth_sources/edit.html.erb b/app/views/auth_sources/edit.html.erb
index e2c99aa3c..87c72724d 100644
--- a/app/views/auth_sources/edit.html.erb
+++ b/app/views/auth_sources/edit.html.erb
@@ -1,7 +1,6 @@
<h2><%=l(:label_auth_source)%> (<%= h(@auth_source.auth_method_name) %>)</h2>
<% form_tag({:action => 'update', :id => @auth_source}, :class => "tabular") do %>
- <%= render :partial => 'form' %>
+ <%= render :partial => auth_source_partial_name(@auth_source) %>
<%= submit_tag l(:button_save) %>
<% end %>
-
diff --git a/app/views/auth_sources/new.html.erb b/app/views/auth_sources/new.html.erb
index d0b9b1d43..e5b9106bd 100644
--- a/app/views/auth_sources/new.html.erb
+++ b/app/views/auth_sources/new.html.erb
@@ -1,6 +1,7 @@
<h2><%=l(:label_auth_source_new)%> (<%= h(@auth_source.auth_method_name) %>)</h2>
<% form_tag({:action => 'create'}, :class => "tabular") do %>
- <%= render :partial => 'form' %>
+ <%= hidden_field_tag 'type', @auth_source.type %>
+ <%= render :partial => auth_source_partial_name(@auth_source) %>
<%= submit_tag l(:button_create) %>
<% end %>