letmein 0.1.3 → 0.1.4

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
@@ -15,7 +15,7 @@ If you want to authenticate *User* with database fields *email*, *password_hash*
15
15
  conf.model = 'Account'
16
16
  conf.attribute = 'username'
17
17
  conf.password = 'password_crypt'
18
- conf.salt = 'salty_salt
18
+ conf.salt = 'salty_salt'
19
19
  end
20
20
 
21
21
  When creating/updating a record you have access to *password* accessor.
@@ -90,7 +90,7 @@ By default user will be logged in if provided email and password match. If you n
90
90
 
91
91
  def authenticate
92
92
  super # need to authenticate with email/password first
93
- if user && user.is_approved?
93
+ unless user && user.is_approved?
94
94
  # adding a validation error will prevent login
95
95
  errors.add :base, "You are not approved yet, #{user.name}."
96
96
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{letmein}
8
- s.version = "0.1.3"
7
+ s.name = "letmein"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov"]
12
- s.date = %q{2011-09-09}
13
- s.description = %q{minimalistic authentication}
14
- s.email = %q{oleg@khabarov.ca}
12
+ s.date = "2011-10-11"
13
+ s.description = "minimalistic authentication"
14
+ s.email = "oleg@khabarov.ca"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.md"
@@ -27,11 +27,11 @@ Gem::Specification.new do |s|
27
27
  "lib/letmein.rb",
28
28
  "test/letmein_test.rb"
29
29
  ]
30
- s.homepage = %q{http://github.com/GBH/letmein}
30
+ s.homepage = "http://github.com/GBH/letmein"
31
31
  s.licenses = ["MIT"]
32
32
  s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.6.2}
34
- s.summary = %q{minimalistic authentication}
33
+ s.rubygems_version = "1.8.10"
34
+ s.summary = "minimalistic authentication"
35
35
  s.test_files = [
36
36
  "test/letmein_test.rb"
37
37
  ]
@@ -90,7 +90,7 @@ module LetMeIn
90
90
  p = LetMeIn.accessor(:password, LetMeIn.config.models.index(self.class.model))
91
91
  s = LetMeIn.accessor(:salt, LetMeIn.config.models.index(self.class.model))
92
92
 
93
- object = self.class.model.constantize.send("find_by_#{self.class.attribute}", self.login)
93
+ object = self.class.model.constantize.where("#{self.class.attribute}" => self.login).first
94
94
  self.object = if object && !object.send(p).blank? && object.send(p) == BCrypt::Engine.hash_secret(self.password, object.send(s))
95
95
  object
96
96
  else
@@ -139,7 +139,12 @@ module LetMeIn
139
139
  self.config.models.each do |model|
140
140
  klass = model.constantize rescue next
141
141
  klass.send :include, LetMeIn::Model
142
- Object.const_set("#{model.to_s.camelize}Session", Class.new(LetMeIn::Session))
142
+
143
+ session_model = "#{model.to_s.camelize}Session"
144
+
145
+ # remove the constant if it's defined, so that we don't get spammed with warnings.
146
+ Object.send(:remove_const, session_model) if (Object.const_get(session_model) rescue nil)
147
+ Object.const_set(session_model, Class.new(LetMeIn::Session))
143
148
  end
144
149
  end
145
150
  end
@@ -107,16 +107,16 @@ class LetMeInTest < Test::Unit::TestCase
107
107
  def test_model_integration
108
108
  assert User.new.respond_to?(:password)
109
109
  user = User.create!(:email => 'test@test.test', :password => 'pass')
110
- assert_match /.{60}/, user.password_hash
111
- assert_match /.{29}/, user.password_salt
110
+ assert_match /^.{60}$/, user.password_hash
111
+ assert_match /^.{29}$/, user.password_salt
112
112
  end
113
113
 
114
114
  def test_model_integration_custom
115
115
  init_custom_configuration
116
116
  assert Admin.new.respond_to?(:password)
117
117
  user = Admin.create!(:username => 'test', :password => 'pass')
118
- assert_match /.{60}/, user.pass_hash
119
- assert_match /.{29}/, user.pass_salt
118
+ assert_match /^.{60}$/, user.pass_hash
119
+ assert_match /^.{29}$/, user.pass_salt
120
120
  end
121
121
 
122
122
  def test_session_initialization
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letmein
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-09 00:00:00.000000000 -04:00
13
- default_executable:
12
+ date: 2011-10-11 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rails
17
- requirement: &70092744394500 !ruby/object:Gem::Requirement
16
+ requirement: &70209998866600 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 3.0.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *70092744394500
24
+ version_requirements: *70209998866600
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: bcrypt-ruby
28
- requirement: &70092744393800 !ruby/object:Gem::Requirement
27
+ requirement: &70209998865920 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *70092744393800
35
+ version_requirements: *70209998865920
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: bundler
39
- requirement: &70092744392980 !ruby/object:Gem::Requirement
38
+ requirement: &70209998864780 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: 1.0.0
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *70092744392980
46
+ version_requirements: *70209998864780
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: jeweler
50
- requirement: &70092744391800 !ruby/object:Gem::Requirement
49
+ requirement: &70209998864040 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,7 +54,7 @@ dependencies:
55
54
  version: 1.5.2
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *70092744391800
57
+ version_requirements: *70209998864040
59
58
  description: minimalistic authentication
60
59
  email: oleg@khabarov.ca
61
60
  executables: []
@@ -73,7 +72,6 @@ files:
73
72
  - letmein.gemspec
74
73
  - lib/letmein.rb
75
74
  - test/letmein_test.rb
76
- has_rdoc: true
77
75
  homepage: http://github.com/GBH/letmein
78
76
  licenses:
79
77
  - MIT
@@ -89,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
87
  version: '0'
90
88
  segments:
91
89
  - 0
92
- hash: 3220175875502170728
90
+ hash: 3289023029845343075
93
91
  required_rubygems_version: !ruby/object:Gem::Requirement
94
92
  none: false
95
93
  requirements:
@@ -98,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
96
  version: '0'
99
97
  requirements: []
100
98
  rubyforge_project:
101
- rubygems_version: 1.6.2
99
+ rubygems_version: 1.8.10
102
100
  signing_key:
103
101
  specification_version: 3
104
102
  summary: minimalistic authentication