26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/devise_pam_authenticatable/model.rb', line 26
def authenticate_with_pam(attributes={})
return nil unless attributes[:username].present?
resource = scoped.where(:username => attributes[:username]).first
if resource.blank?
resource = new
resource[:username] = attributes[:username]
resource[:password] = attributes[:password]
end
if resource.try(:valid_pam_authentication?, attributes[:password])
resource.save if resource.new_record?
return resource
else
return nil
end
end
|