Module: AuthlogicPam::Session::Methods

Defined in:
lib/authlogic_pam/session.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/authlogic_pam/session.rb', line 21

def self.included(klass)
  klass.class_eval do
    attr_accessor :pam_login
    attr_accessor :pam_password
    
    validate :validate_by_pam, :if => :authenticating_with_pam?
  end
end

Instance Method Details

#credentialsObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/authlogic_pam/session.rb', line 30

def credentials
  if authenticating_with_pam?
    details = {}
    details[:pam_login] = send()
    details[:pam_password] = '<protected>'
    details
  else
    super
  end
end

#credentials=(value) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/authlogic_pam/session.rb', line 41

def credentials=(value)
  super
  values = value.is_a?(Array) ? value : [value]
  hash = values.first.is_a?(Hash) ? values.first.with_indifferent_access : nil
  if !hash.nil?
    self. = hash[:pam_login] if hash.key?(:pam_login)
    self.pam_password = hash[:pam_password] if hash.key?(:pam_password)
  end
end