simplest_auth 0.2.2 → 0.2.3

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/Rakefile CHANGED
@@ -7,14 +7,15 @@ require 'lib/simplest_auth/version'
7
7
  task :default => :test
8
8
 
9
9
  spec = Gem::Specification.new do |s|
10
- s.name = 'simplest_auth'
11
- s.version = SimplestAuth::Version.to_s
12
- s.summary = "Simple implementation of authentication for Rails"
13
- s.author = 'Tony Pitale'
14
- s.email = 'tony.pitale@viget.com'
15
- s.homepage = 'http://viget.com/extend'
16
- s.files = %w(README.textile Rakefile) + Dir.glob("lib/**/*")
17
- s.test_files = Dir.glob("test/**/*_test.rb")
10
+ s.name = 'simplest_auth'
11
+ s.rubyforge_project = 'viget'
12
+ s.version = SimplestAuth::Version.to_s
13
+ s.summary = "Simple implementation of authentication for Rails"
14
+ s.author = 'Tony Pitale'
15
+ s.email = 'tony.pitale@viget.com'
16
+ s.homepage = 'http://viget.com/extend'
17
+ s.files = %w(README.textile Rakefile) + Dir.glob("lib/**/*")
18
+ s.test_files = Dir.glob("test/**/*_test.rb")
18
19
 
19
20
  s.add_dependency('bcrypt-ruby', '~> 2.1.1')
20
21
  end
@@ -29,28 +29,29 @@ module SimplestAuth
29
29
  end
30
30
 
31
31
  def authenticate(email, password)
32
+ user = nil
32
33
  if active_record?
33
- klass = find_by_email(email)
34
+ user = find_by_email(email)
34
35
  elsif data_mapper?
35
- klass = first(:email => email)
36
+ user = first(:email => email)
36
37
  end
37
38
 
38
- (klass && klass.authentic?(password)) ? klass : nil
39
+ (user && user.authentic?(password)) ? user : nil
39
40
  end
40
41
 
41
42
  def authenticate_by(ident)
42
43
  if active_record?
43
44
  instance_eval <<-EOM
44
45
  def authenticate(#{ident}, password)
45
- klass = find_by_#{ident}(#{ident})
46
- (klass && klass.authentic?(password)) ? klass : nil
46
+ user = find_by_#{ident}(#{ident})
47
+ (user && user.authentic?(password)) ? user : nil
47
48
  end
48
49
  EOM
49
50
  elsif data_mapper?
50
51
  instance_eval <<-EOM
51
52
  def authenticate(#{ident}, password)
52
- klass = first(:#{ident} => #{ident})
53
- (klass && klass.authentic?(password)) ? klass : nil
53
+ user = first(:#{ident} => #{ident})
54
+ (user && user.authentic?(password)) ? user : nil
54
55
  end
55
56
  EOM
56
57
  end
@@ -71,7 +72,11 @@ module SimplestAuth
71
72
  RecordNotFound = Class.new(StandardError) unless defined?(RecordNotFound)
72
73
 
73
74
  def authentic?(password)
74
- Password.new(self.crypted_password) == password
75
+ begin
76
+ return Password.new(self.crypted_password) == password
77
+ rescue BCrypt::Errors::InvalidHash
78
+ return false
79
+ end
75
80
  end
76
81
 
77
82
  private
@@ -3,7 +3,7 @@ module SimplestAuth
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 2
6
+ TINY = 3
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplest_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-18 00:00:00 -04:00
12
+ date: 2009-10-13 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version:
65
65
  requirements: []
66
66
 
67
- rubyforge_project:
67
+ rubyforge_project: viget
68
68
  rubygems_version: 1.3.5
69
69
  signing_key:
70
70
  specification_version: 3