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

auth_sources_controller.rb 2.9 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 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. before_filter :find_auth_source, :only => [:edit, :update, :test_connection, :destroy]
  22. def index
  23. @auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 25
  24. end
  25. def new
  26. klass_name = params[:type] || 'AuthSourceLdap'
  27. @auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source])
  28. render_404 unless @auth_source
  29. end
  30. def create
  31. @auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source])
  32. if @auth_source.save
  33. flash[:notice] = l(:notice_successful_create)
  34. redirect_to auth_sources_path
  35. else
  36. render :action => 'new'
  37. end
  38. end
  39. def edit
  40. end
  41. def update
  42. if @auth_source.update_attributes(params[:auth_source])
  43. flash[:notice] = l(:notice_successful_update)
  44. redirect_to auth_sources_path
  45. else
  46. render :action => 'edit'
  47. end
  48. end
  49. def test_connection
  50. begin
  51. @auth_source.test_connection
  52. flash[:notice] = l(:notice_successful_connection)
  53. rescue Exception => e
  54. flash[:error] = l(:error_unable_to_connect, e.message)
  55. end
  56. redirect_to auth_sources_path
  57. end
  58. def destroy
  59. unless @auth_source.users.exists?
  60. @auth_source.destroy
  61. flash[:notice] = l(:notice_successful_delete)
  62. end
  63. redirect_to auth_sources_path
  64. end
  65. def autocomplete_for_new_user
  66. results = AuthSource.search(params[:term])
  67. render :json => results.map {|result| {
  68. 'value' => result[:login],
  69. 'label' => "#{result[:login]} (#{result[:firstname]} #{result[:lastname]})",
  70. 'login' => result[:login].to_s,
  71. 'firstname' => result[:firstname].to_s,
  72. 'lastname' => result[:lastname].to_s,
  73. 'mail' => result[:mail].to_s,
  74. 'auth_source_id' => result[:auth_source_id].to_s
  75. }}
  76. end
  77. private
  78. def find_auth_source
  79. @auth_source = AuthSource.find(params[:id])
  80. rescue ActiveRecord::RecordNotFound
  81. render_404
  82. end
  83. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...