1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 class AuthSourcesController < ApplicationController
21 before_filter :require_admin
23 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
24 verify :method => :post, :only => [ :destroy, :create, :update ],
25 :redirect_to => { :template => :index }
28 @auth_source_pages, @auth_sources = paginate auth_source_class.name.tableize, :per_page => 10
29 render "auth_sources/index"
33 @auth_source = auth_source_class.new
34 render 'auth_sources/new'
38 @auth_source = auth_source_class.new(params[:auth_source])
40 flash[:notice] = l(:notice_successful_create)
41 redirect_to :action => 'index'
43 render 'auth_sources/new'
48 @auth_source = AuthSource.find(params[:id])
49 render 'auth_sources/edit'
53 @auth_source = AuthSource.find(params[:id])
54 if @auth_source.update_attributes(params[:auth_source])
55 flash[:notice] = l(:notice_successful_update)
56 redirect_to :action => 'index'
58 render 'auth_sources/edit'
63 @auth_method = AuthSource.find(params[:id])
65 @auth_method.test_connection
66 flash[:notice] = l(:notice_successful_connection)
68 flash[:error] = l(:error_unable_to_connect, text.message)
70 redirect_to :action => 'index'
74 @auth_source = AuthSource.find(params[:id])
75 unless @auth_source.users.find(:first)
77 flash[:notice] = l(:notice_successful_delete)
79 redirect_to :action => 'index'