Module: Devise::Models::AdUser::ClassMethods
- Defined in:
- lib/devise_active_directory_authenticatable/models/ad_user.rb
Instance Method Summary collapse
- #activedirectory_class ⇒ Object
-
#authenticate_with_activedirectory(attributes = {}) ⇒ Object
Authenticate a user based on configured attribute keys.
-
#devise_model ⇒ Object
TODO find a way to get rid of this with metaprogramming.
Instance Method Details
#activedirectory_class ⇒ Object
39 40 41 |
# File 'lib/devise_active_directory_authenticatable/models/ad_user.rb', line 39 def activedirectory_class ActiveDirectory::User end |
#authenticate_with_activedirectory(attributes = {}) ⇒ Object
Authenticate a user based on configured attribute keys. Returns the authenticated user if it’s valid or nil.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/devise_active_directory_authenticatable/models/ad_user.rb', line 45 def authenticate_with_activedirectory(attributes={}) username = attributes[login_with] password = attributes[:password] Logger.send "Attempting to login :#{@login_with} => #{username}" set_activedirectory_credentials :username => username, :password => password activedirectory_connect Logger.send "Attempt Result: #{ActiveDirectory::Base.error}" # Find them in the local database user = find_or_create_from_activedirectory(login_with => attributes[login_with]).first # Check to see if we have the same user unless user.nil? user.save if user.new_record? and ::Devise.ad_create_user user.login if user.respond_to?(:login) return user else raise DeviseActiveDirectoryAuthenticatable::ActiveDirectoryException, "Active Directory user and entry in local database have different GUIDs. Possible database inconsistency." end end |
#devise_model ⇒ Object
TODO find a way to get rid of this with metaprogramming
35 36 37 |
# File 'lib/devise_active_directory_authenticatable/models/ad_user.rb', line 35 def devise_model AdUser end |