Module: Authlogic::Session::UnauthorizedRecord
- Included in:
- Base
- Defined in:
- lib/authlogic/session/unauthorized_record.rb
Overview
Allows you to create session with an object. Ex:
UserSession.create(my_user_object)
Be careful with this, because Authlogic is assuming that you have already confirmed that the user is who he says he is.
For example, this is the method used to persist the session internally. Authlogic finds the user with the persistence token. At this point we know the user is who he says he is, so Authlogic just creates a session with the record. This is particularly useful for 3rd party authentication methods, such as OpenID. Let that method verify the identity, once it’s verified, pass the object and create a session.
Class Method Summary collapse
Instance Method Summary collapse
-
#credentials ⇒ Object
Returning meaningful credentials.
-
#credentials=(value) ⇒ Object
Setting the unauthorized record if it exists in the credentials passed.
Class Method Details
.included(klass) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/authlogic/session/unauthorized_record.rb', line 15 def self.included(klass) klass.class_eval do attr_accessor :unauthorized_record validate :validate_by_unauthorized_record, :if => :authenticating_with_unauthorized_record? end end |
Instance Method Details
#credentials ⇒ Object
Returning meaningful credentials
23 24 25 26 27 28 29 30 31 |
# File 'lib/authlogic/session/unauthorized_record.rb', line 23 def credentials if details = {} details[:unauthorized_record] = "<protected>" details else super end end |
#credentials=(value) ⇒ Object
Setting the unauthorized record if it exists in the credentials passed.
34 35 36 37 38 |
# File 'lib/authlogic/session/unauthorized_record.rb', line 34 def credentials=(value) super values = value.is_a?(Array) ? value : [value] self. = values.first if values.first.class < ::ActiveRecord::Base end |