Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.authenticate(username, password)
- user = User.find(:first, :conditions => ["username = ?", username])
- **** case authenticate_ldap_user(username, password) ****
- when String
- # User authenticated via LDAP.
- if user.blank?
- user = User.new(:username => username, :password_salt => new_salt)
- user.roles << Role.find_by_name('identified')
- end
- user.password = password and user.save! if user.password_hash != encrypted(password, user.password_salt)
- return user if user && user.password_hash == encrypted(password, user.password_salt)
- when FalseClass
- # LDAP raised an exception.
- return false
- when NilClass
- # User not authenticated via LDAP.
- return nil
- end
- end
Add Comment
Please, Sign In to add comment