Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

auth_source.rb 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # redMine - project management software
  2. # Copyright (C) 2006 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 AuthSource < ActiveRecord::Base
  18. has_many :users
  19. validates_presence_of :name
  20. validates_uniqueness_of :name
  21. def authenticate(login, password)
  22. end
  23. def test_connection
  24. end
  25. def auth_method_name
  26. "Abstract"
  27. end
  28. # Try to authenticate a user not yet registered against available sources
  29. def self.authenticate(login, password)
  30. AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source|
  31. begin
  32. logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug?
  33. attrs = source.authenticate(login, password)
  34. rescue
  35. attrs = nil
  36. end
  37. return attrs if attrs
  38. end
  39. return nil
  40. end
  41. end