You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth_sources_controller.rb 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2012 Jean-Philippe Lang
  3. #
  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.
  8. #
  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.
  13. #
  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.
  17. class AuthSourcesController < ApplicationController
  18. layout 'admin'
  19. menu_item :ldap_authentication
  20. before_filter :require_admin
  21. def index
  22. @auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 10
  23. end
  24. def new
  25. klass_name = params[:type] || 'AuthSourceLdap'
  26. @auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source])
  27. end
  28. def create
  29. @auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source])
  30. if @auth_source.save
  31. flash[:notice] = l(:notice_successful_create)
  32. redirect_to :action => 'index'
  33. else
  34. render :action => 'new'
  35. end
  36. end
  37. def edit
  38. @auth_source = AuthSource.find(params[:id])
  39. end
  40. def update
  41. @auth_source = AuthSource.find(params[:id])
  42. if @auth_source.update_attributes(params[:auth_source])
  43. flash[:notice] = l(:notice_successful_update)
  44. redirect_to :action => 'index'
  45. else
  46. render :action => 'edit'
  47. end
  48. end
  49. def test_connection
  50. @auth_source = AuthSource.find(params[:id])
  51. begin
  52. @auth_source.test_connection
  53. flash[:notice] = l(:notice_successful_connection)
  54. rescue Exception => e
  55. flash[:error] = l(:error_unable_to_connect, e.message)
  56. end
  57. redirect_to :action => 'index'
  58. end
  59. def destroy
  60. @auth_source = AuthSource.find(params[:id])
  61. unless @auth_source.users.find(:first)
  62. @auth_source.destroy
  63. flash[:notice] = l(:notice_successful_delete)
  64. end
  65. redirect_to :action => 'index'
  66. end
  67. end