Mercurial > hg > soundsoftware-site
diff app/controllers/auth_sources_controller.rb @ 1338:25603efa57b5
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:14 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 |
line wrap: on
line diff
--- a/app/controllers/auth_sources_controller.rb Wed Jan 23 13:11:25 2013 +0000 +++ b/app/controllers/auth_sources_controller.rb Thu Jun 20 13:14:14 2013 +0100 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 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 @@ -17,36 +17,31 @@ class AuthSourcesController < ApplicationController layout 'admin' + menu_item :ldap_authentication before_filter :require_admin - # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) - verify :method => :post, :only => [ :destroy, :create, :update ], - :redirect_to => { :template => :index } - 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 @@ -55,17 +50,17 @@ 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 => text - flash[:error] = l(:error_unable_to_connect, text.message) + rescue Exception => e + flash[:error] = l(:error_unable_to_connect, e.message) end redirect_to :action => 'index' end @@ -78,10 +73,4 @@ end redirect_to :action => 'index' end - - protected - - def auth_source_class - AuthSource - end end