Guest User

Untitled

a guest
May 26th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. def self.authenticate(username, password)
  2. user = User.find(:first, :conditions => ["username = ?", username])
  3. **** case authenticate_ldap_user(username, password) ****
  4. when String
  5. # User authenticated via LDAP.
  6. if user.blank?
  7. user = User.new(:username => username, :password_salt => new_salt)
  8. user.roles << Role.find_by_name('identified')
  9. end
  10. user.password = password and user.save! if user.password_hash != encrypted(password, user.password_salt)
  11. return user if user && user.password_hash == encrypted(password, user.password_salt)
  12. when FalseClass
  13. # LDAP raised an exception.
  14. return false
  15. when NilClass
  16. # User not authenticated via LDAP.
  17. return nil
  18. end
  19. end
Add Comment
Please, Sign In to add comment