devise_pam_authenticatable 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -17,6 +17,10 @@ Installation
17
17
 
18
18
  In the Gemfile for your application:
19
19
 
20
+ gem "devise_pam_authenticatable"
21
+
22
+ Or, to use the latest from github:
23
+
20
24
  gem "devise_pam_authenticatable", :git => "git://github.com/jwilson511/devise_pam_authenticatable.git"
21
25
 
22
26
  Setup
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{devise_pam_authenticatable}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Wilson"]
@@ -26,9 +26,12 @@ module Devise
26
26
  def authenticate_with_pam(attributes={})
27
27
  return nil unless attributes[:username].present?
28
28
 
29
- resource = new
30
- resource[:username] = attributes[:username]
31
- resource[:password] = attributes[:password]
29
+ resource = scoped.where(:username => attributes[:username]).first
30
+ if resource.blank?
31
+ resource = new
32
+ resource[:username] = attributes[:username]
33
+ resource[:password] = attributes[:password]
34
+ end
32
35
 
33
36
  if resource.try(:valid_pam_authentication?, attributes[:password])
34
37
  resource.save if resource.new_record?
@@ -5,12 +5,10 @@ module Devise
5
5
  class PamAuthenticatable < Base
6
6
 
7
7
  def valid?
8
- puts "Asked if valid"
9
8
  valid_controller? && valid_params? && mapping.to.respond_to?(:authenticate_with_pam)
10
9
  end
11
10
 
12
11
  def authenticate!
13
- puts "Asked to authenticate"
14
12
  if resource = mapping.to.authenticate_with_pam(params[scope])
15
13
  success!(resource)
16
14
  else
@@ -21,12 +19,10 @@ module Devise
21
19
  protected
22
20
 
23
21
  def valid_controller?
24
- puts "Controller is #{params[:controller]}"
25
22
  params[:controller] == 'devise/sessions'
26
23
  end
27
24
 
28
25
  def valid_params?
29
- puts "Scope is #{params[scope]}"
30
26
  params[scope] && params[scope][:password].present?
31
27
  end
32
28
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_pam_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Wilson