Module: Devise::Models::CasAuthenticatable::ClassMethods
- Defined in:
- lib/devise_cas_authenticatable/model.rb
Instance Method Summary collapse
-
#authenticate_with_cas_details(cas_details) ⇒ Object
Given a CAS details hash returned by rack-cas, return the resulting user object.
Instance Method Details
#authenticate_with_cas_details(cas_details) ⇒ Object
Given a CAS details hash returned by rack-cas, return the resulting user object. Behavior is as follows:
-
Find a matching user by username (will use find_for_authentication if available).
-
If the user does not exist, but Devise.cas_create_user is set, attempt to create the user object in the database. If cas_extra_attributes= is defined, this will also pass in the extra_attributes hash.
-
Return the resulting user object.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/devise_cas_authenticatable/model.rb', line 18 def authenticate_with_cas_details(cas_details) identifier = cas_details['user'] # If cas_user_identifier isn't in extra_attributes, # or the value is blank, then we're done here return log_and_exit if identifier.nil? logger.debug("Using conditions {#{::Devise.cas_username_column} => #{identifier}} to find the User") conditions = { ::Devise.cas_username_column => identifier } resource = find_or_build_resource_from_conditions(conditions) return nil unless resource if resource.respond_to?(:cas_extra_attributes=) resource.cas_extra_attributes = cas_details['extra_attributes'] end resource.save resource end |