letmein 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile.lock +69 -54
- data/README.md +18 -2
- data/VERSION +1 -1
- data/letmein.gemspec +3 -2
- data/lib/letmein.rb +86 -76
- data/test/letmein_test.rb +49 -16
- metadata +12 -11
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,75 +1,90 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rack (~> 1.
|
15
|
-
rack-mount (~> 0.
|
16
|
-
rack-test (~> 0.
|
17
|
-
|
18
|
-
activemodel (3.0
|
19
|
-
activesupport (= 3.0
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
4
|
+
actionmailer (3.1.0)
|
5
|
+
actionpack (= 3.1.0)
|
6
|
+
mail (~> 2.3.0)
|
7
|
+
actionpack (3.1.0)
|
8
|
+
activemodel (= 3.1.0)
|
9
|
+
activesupport (= 3.1.0)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
i18n (~> 0.6)
|
13
|
+
rack (~> 1.3.2)
|
14
|
+
rack-cache (~> 1.0.3)
|
15
|
+
rack-mount (~> 0.8.2)
|
16
|
+
rack-test (~> 0.6.1)
|
17
|
+
sprockets (~> 2.0.0)
|
18
|
+
activemodel (3.1.0)
|
19
|
+
activesupport (= 3.1.0)
|
20
|
+
bcrypt-ruby (~> 3.0.0)
|
21
|
+
builder (~> 3.0.0)
|
22
|
+
i18n (~> 0.6)
|
23
|
+
activerecord (3.1.0)
|
24
|
+
activemodel (= 3.1.0)
|
25
|
+
activesupport (= 3.1.0)
|
26
|
+
arel (~> 2.2.1)
|
27
|
+
tzinfo (~> 0.3.29)
|
28
|
+
activeresource (3.1.0)
|
29
|
+
activemodel (= 3.1.0)
|
30
|
+
activesupport (= 3.1.0)
|
31
|
+
activesupport (3.1.0)
|
32
|
+
multi_json (~> 1.0)
|
33
|
+
arel (2.2.1)
|
34
|
+
bcrypt-ruby (3.0.0)
|
35
|
+
builder (3.0.0)
|
36
|
+
erubis (2.7.0)
|
36
37
|
git (1.2.5)
|
37
|
-
|
38
|
+
hike (1.2.1)
|
39
|
+
i18n (0.6.0)
|
38
40
|
jeweler (1.5.2)
|
39
41
|
bundler (~> 1.0.0)
|
40
42
|
git (>= 1.2.5)
|
41
43
|
rake
|
42
|
-
mail (2.
|
43
|
-
activesupport (>= 2.3.6)
|
44
|
+
mail (2.3.0)
|
44
45
|
i18n (>= 0.4.0)
|
45
46
|
mime-types (~> 1.16)
|
46
47
|
treetop (~> 1.4.8)
|
47
48
|
mime-types (1.16)
|
48
|
-
|
49
|
-
|
50
|
-
rack
|
49
|
+
multi_json (1.0.3)
|
50
|
+
polyglot (0.3.2)
|
51
|
+
rack (1.3.2)
|
52
|
+
rack-cache (1.0.3)
|
53
|
+
rack (>= 0.4)
|
54
|
+
rack-mount (0.8.3)
|
51
55
|
rack (>= 1.0.0)
|
52
|
-
rack-
|
56
|
+
rack-ssl (1.3.2)
|
57
|
+
rack
|
58
|
+
rack-test (0.6.1)
|
53
59
|
rack (>= 1.0)
|
54
|
-
rails (3.0
|
55
|
-
actionmailer (= 3.0
|
56
|
-
actionpack (= 3.0
|
57
|
-
activerecord (= 3.0
|
58
|
-
activeresource (= 3.0
|
59
|
-
activesupport (= 3.0
|
60
|
+
rails (3.1.0)
|
61
|
+
actionmailer (= 3.1.0)
|
62
|
+
actionpack (= 3.1.0)
|
63
|
+
activerecord (= 3.1.0)
|
64
|
+
activeresource (= 3.1.0)
|
65
|
+
activesupport (= 3.1.0)
|
60
66
|
bundler (~> 1.0)
|
61
|
-
railties (= 3.0
|
62
|
-
railties (3.0
|
63
|
-
actionpack (= 3.0
|
64
|
-
activesupport (= 3.0
|
67
|
+
railties (= 3.1.0)
|
68
|
+
railties (3.1.0)
|
69
|
+
actionpack (= 3.1.0)
|
70
|
+
activesupport (= 3.1.0)
|
71
|
+
rack-ssl (~> 1.3.2)
|
65
72
|
rake (>= 0.8.7)
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
rdoc (~> 3.4)
|
74
|
+
thor (~> 0.14.6)
|
75
|
+
rake (0.9.2)
|
76
|
+
rdoc (3.9.4)
|
77
|
+
sprockets (2.0.0)
|
78
|
+
hike (~> 1.2)
|
79
|
+
rack (~> 1.0)
|
80
|
+
tilt (!= 1.3.0, ~> 1.1)
|
81
|
+
sqlite3 (1.3.4)
|
69
82
|
thor (0.14.6)
|
70
|
-
|
83
|
+
tilt (1.3.3)
|
84
|
+
treetop (1.4.10)
|
85
|
+
polyglot
|
71
86
|
polyglot (>= 0.3.1)
|
72
|
-
tzinfo (0.3.
|
87
|
+
tzinfo (0.3.29)
|
73
88
|
|
74
89
|
PLATFORMS
|
75
90
|
ruby
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ If you want to authenticate *User* with database fields *email*, *password_hash*
|
|
14
14
|
|
15
15
|
LetMeIn.configure do |conf|
|
16
16
|
conf.model = 'Account'
|
17
|
-
conf.
|
17
|
+
conf.attribute = 'username'
|
18
18
|
conf.password = 'password_crypt'
|
19
19
|
conf.salt = 'salty_salt
|
20
20
|
end
|
@@ -75,11 +75,27 @@ Yes, you can do that too. Let's assume you also want to authenticate admins that
|
|
75
75
|
|
76
76
|
LetMeIn.configure do |conf|
|
77
77
|
conf.models = ['User', 'Admin']
|
78
|
-
conf.
|
78
|
+
conf.attributes = ['email', 'username']
|
79
79
|
end
|
80
80
|
|
81
81
|
Bam! You're done. Now you have an AdminSession object that will use *username* and *password* to authenticate.
|
82
82
|
|
83
|
+
Overriding Session Authentication
|
84
|
+
=================================
|
85
|
+
By default user will be logged in if provided email and password match. If you need to add a bit more logic to that you'll need to create your own session object. In the following example we do an additional check to see if user is 'approved' before letting him in.
|
86
|
+
|
87
|
+
class MySession < LetMeIn::Session
|
88
|
+
@model, @attribute = 'User', 'email' # need to know what model we're validating
|
89
|
+
|
90
|
+
def authenticate
|
91
|
+
super # need to authenticate with email/password first
|
92
|
+
if user && user.is_approved?
|
93
|
+
# adding a validation error will prevent login
|
94
|
+
errors.add :base, 'You are not approved yet'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
83
99
|
Copyright
|
84
100
|
=========
|
85
101
|
(c) 2011 Oleg Khabarov, released under the MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/letmein.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{letmein}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
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-
|
12
|
+
s.date = %q{2011-09-09}
|
13
13
|
s.description = %q{minimalistic authentication}
|
14
14
|
s.email = %q{oleg@khabarov.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
+
".travis.yml",
|
20
21
|
"Gemfile",
|
21
22
|
"Gemfile.lock",
|
22
23
|
"LICENSE",
|
data/lib/letmein.rb
CHANGED
@@ -17,11 +17,11 @@ module LetMeIn
|
|
17
17
|
# conf.identifier = 'username'
|
18
18
|
# end
|
19
19
|
class Config
|
20
|
-
ACCESSORS = %w(models
|
20
|
+
ACCESSORS = %w(models attributes passwords salts)
|
21
21
|
attr_accessor *ACCESSORS
|
22
22
|
def initialize
|
23
23
|
@models = ['User']
|
24
|
-
@
|
24
|
+
@attributes = ['email']
|
25
25
|
@passwords = ['password_hash']
|
26
26
|
@salts = ['password_salt']
|
27
27
|
end
|
@@ -32,84 +32,73 @@ module LetMeIn
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def self.configure
|
40
|
-
yield config
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.initialize
|
35
|
+
# LetMeIn::Session object. Things like UserSession are created
|
36
|
+
# automatically after the initialization
|
37
|
+
class Session
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
# class MySession < LetMeIn::Session
|
40
|
+
# @model = 'User'
|
41
|
+
# @attribute = 'email'
|
42
|
+
# end
|
43
|
+
class << self
|
44
|
+
attr_accessor :model, :attribute
|
48
45
|
end
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
include ActiveModel::Validations
|
48
|
+
|
49
|
+
attr_accessor :login, # test@test.test
|
50
|
+
:password, # secretpassword
|
51
|
+
:object # authenticated object
|
52
|
+
|
53
|
+
validate :authenticate
|
54
|
+
|
55
|
+
def initialize(params = { })
|
56
|
+
self.class.model ||= self.class.to_s.gsub('Session', '') || LetMeIn.config.models.first
|
57
|
+
self.class.attribute ||= LetMeIn.accessor(:attribute, LetMeIn.config.models.index(self.class.model))
|
58
|
+
self.login = params[:login] || params[self.class.attribute.to_sym]
|
59
|
+
self.password = params[:password]
|
60
|
+
end
|
61
|
+
|
62
|
+
def save
|
63
|
+
self.valid?
|
64
|
+
end
|
65
|
+
|
66
|
+
def save!
|
67
|
+
save || raise(LetMeIn::Error, 'Failed to authenticate')
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.create(params = {})
|
71
|
+
object = self.new(params); object.save; object
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.create!(params = {})
|
75
|
+
object = self.new(params); object.save!; object
|
76
|
+
end
|
77
|
+
|
78
|
+
def method_missing(method_name, *args)
|
79
|
+
case method_name.to_s
|
80
|
+
when self.class.attribute then self.login
|
81
|
+
when "#{self.class.attribute}=" then self.login = args[0]
|
82
|
+
when self.class.model.underscore then self.object
|
83
|
+
else super
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def authenticate
|
88
|
+
p = LetMeIn.accessor(:password, LetMeIn.config.models.index(self.class.model))
|
89
|
+
s = LetMeIn.accessor(:salt, LetMeIn.config.models.index(self.class.model))
|
54
90
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def save
|
69
|
-
self.valid?
|
70
|
-
end
|
71
|
-
|
72
|
-
def save!
|
73
|
-
save || raise(LetMeIn::Error, 'Failed to authenticate')
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.create(params = {})
|
77
|
-
object = self.new(params); object.save; object
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.create!(params = {})
|
81
|
-
object = self.new(params); object.save!; object
|
82
|
-
end
|
83
|
-
|
84
|
-
def method_missing(method_name, *args)
|
85
|
-
m = self.class.to_s.gsub('Session','')
|
86
|
-
i = LetMeIn.accessor(:identifier, LetMeIn.config.models.index(m))
|
87
|
-
case method_name.to_s
|
88
|
-
when i then self.identifier
|
89
|
-
when "#{i}=" then self.identifier = args[0]
|
90
|
-
when m.underscore then self.authenticated_object
|
91
|
-
else super
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def authenticate
|
96
|
-
m = self.class.to_s.gsub('Session','')
|
97
|
-
i = LetMeIn.accessor(:identifier, LetMeIn.config.models.index(m))
|
98
|
-
p = LetMeIn.accessor(:password, LetMeIn.config.models.index(m))
|
99
|
-
s = LetMeIn.accessor(:password, LetMeIn.config.models.index(m))
|
100
|
-
object = m.constantize.send("find_by_#{i}", self.identifier)
|
101
|
-
self.authenticated_object = if object && !object.send(p).blank? && object.send(p) == BCrypt::Engine.hash_secret(self.password, object.send(s))
|
102
|
-
object
|
103
|
-
else
|
104
|
-
errors.add :base, 'Failed to authenticate'
|
105
|
-
nil
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def to_key
|
110
|
-
nil
|
111
|
-
end
|
112
|
-
end)
|
91
|
+
object = self.class.model.constantize.send("find_by_#{self.class.attribute}", self.login)
|
92
|
+
self.object = if object && !object.send(p).blank? && object.send(p) == BCrypt::Engine.hash_secret(self.password, object.send(s))
|
93
|
+
object
|
94
|
+
else
|
95
|
+
errors.add :base, 'Failed to authenticate'
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_key
|
101
|
+
nil
|
113
102
|
end
|
114
103
|
end
|
115
104
|
|
@@ -130,4 +119,25 @@ module LetMeIn
|
|
130
119
|
end
|
131
120
|
end
|
132
121
|
end
|
122
|
+
|
123
|
+
def self.config
|
124
|
+
@config ||= Config.new
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.configure
|
128
|
+
yield config
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.initialize
|
132
|
+
def self.accessor(name, index = 0)
|
133
|
+
name = name.to_s.pluralize
|
134
|
+
self.config.send(name)[index] || self.config.send(name)[0]
|
135
|
+
end
|
136
|
+
|
137
|
+
self.config.models.each do |model|
|
138
|
+
klass = model.constantize rescue next
|
139
|
+
klass.send :include, LetMeIn::Model
|
140
|
+
Object.const_set("#{model.to_s.camelize}Session", Class.new(LetMeIn::Session))
|
141
|
+
end
|
142
|
+
end
|
133
143
|
end
|
data/test/letmein_test.rb
CHANGED
@@ -10,7 +10,23 @@ $stdout = StringIO.new
|
|
10
10
|
class User < ActiveRecord::Base ; end
|
11
11
|
class Admin < ActiveRecord::Base ; end
|
12
12
|
|
13
|
+
class OpenSession < LetMeIn::Session
|
14
|
+
@model, @attribute = 'User', 'email'
|
15
|
+
def authenticate
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class ClosedSession < LetMeIn::Session
|
21
|
+
@model, @attribute = 'User', 'email'
|
22
|
+
def authenticate
|
23
|
+
super
|
24
|
+
errors.add :base, "You shall not pass #{user.email}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
13
28
|
class LetMeInTest < Test::Unit::TestCase
|
29
|
+
|
14
30
|
def setup
|
15
31
|
ActiveRecord::Base.logger
|
16
32
|
ActiveRecord::Schema.define(:version => 1) do
|
@@ -32,7 +48,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
32
48
|
remove_session_classes
|
33
49
|
LetMeIn.configure do |c|
|
34
50
|
c.models = ['User']
|
35
|
-
c.
|
51
|
+
c.attributes = ['email']
|
36
52
|
c.passwords = ['password_hash']
|
37
53
|
c.salts = ['password_salt']
|
38
54
|
end
|
@@ -43,7 +59,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
43
59
|
remove_session_classes
|
44
60
|
LetMeIn.configure do |c|
|
45
61
|
c.models = ['User', 'Admin']
|
46
|
-
c.
|
62
|
+
c.attributes = ['email', 'username']
|
47
63
|
c.passwords = ['password_hash', 'pass_hash']
|
48
64
|
c.salts = ['password_salt', 'pass_salt']
|
49
65
|
end
|
@@ -65,7 +81,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
65
81
|
# -- Tests ----------------------------------------------------------------
|
66
82
|
def test_default_configuration_initialization
|
67
83
|
assert_equal ['User'], LetMeIn.config.models
|
68
|
-
assert_equal ['email'], LetMeIn.config.
|
84
|
+
assert_equal ['email'], LetMeIn.config.attributes
|
69
85
|
assert_equal ['password_hash'], LetMeIn.config.passwords
|
70
86
|
assert_equal ['password_salt'], LetMeIn.config.salts
|
71
87
|
end
|
@@ -73,12 +89,12 @@ class LetMeInTest < Test::Unit::TestCase
|
|
73
89
|
def test_custom_configuration_initialization
|
74
90
|
LetMeIn.configure do |c|
|
75
91
|
c.model = 'Account'
|
76
|
-
c.
|
92
|
+
c.attribute = 'username'
|
77
93
|
c.password = 'encrypted_pass'
|
78
94
|
c.salt = 'salt'
|
79
95
|
end
|
80
96
|
assert_equal ['Account'], LetMeIn.config.models
|
81
|
-
assert_equal ['username'], LetMeIn.config.
|
97
|
+
assert_equal ['username'], LetMeIn.config.attributes
|
82
98
|
assert_equal ['encrypted_pass'], LetMeIn.config.passwords
|
83
99
|
assert_equal ['salt'], LetMeIn.config.salts
|
84
100
|
end
|
@@ -101,15 +117,15 @@ class LetMeInTest < Test::Unit::TestCase
|
|
101
117
|
def test_session_initialization
|
102
118
|
assert defined?(UserSession)
|
103
119
|
session = UserSession.new(:email => 'test@test.test', :password => 'pass')
|
104
|
-
assert_equal 'test@test.test', session.
|
120
|
+
assert_equal 'test@test.test', session.login
|
105
121
|
assert_equal 'test@test.test', session.email
|
106
122
|
assert_equal 'pass', session.password
|
107
123
|
|
108
124
|
session.email = 'new_user@test.test'
|
109
|
-
assert_equal 'new_user@test.test', session.
|
125
|
+
assert_equal 'new_user@test.test', session.login
|
110
126
|
assert_equal 'new_user@test.test', session.email
|
111
127
|
|
112
|
-
assert_equal nil, session.
|
128
|
+
assert_equal nil, session.object
|
113
129
|
assert_equal nil, session.user
|
114
130
|
end
|
115
131
|
|
@@ -117,15 +133,15 @@ class LetMeInTest < Test::Unit::TestCase
|
|
117
133
|
init_custom_configuration
|
118
134
|
assert defined?(AdminSession)
|
119
135
|
session = AdminSession.new(:username => 'admin', :password => 'test_pass')
|
120
|
-
assert_equal 'admin', session.
|
136
|
+
assert_equal 'admin', session.login
|
121
137
|
assert_equal 'admin', session.username
|
122
138
|
assert_equal 'test_pass', session.password
|
123
139
|
|
124
140
|
session.username = 'new_admin'
|
125
|
-
assert_equal 'new_admin', session.
|
141
|
+
assert_equal 'new_admin', session.login
|
126
142
|
assert_equal 'new_admin', session.username
|
127
143
|
|
128
|
-
assert_equal nil, session.
|
144
|
+
assert_equal nil, session.object
|
129
145
|
assert_equal nil, session.admin
|
130
146
|
end
|
131
147
|
|
@@ -133,7 +149,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
133
149
|
user = User.create!(:email => 'test@test.test', :password => 'pass')
|
134
150
|
session = UserSession.create(:email => user.email, :password => 'pass')
|
135
151
|
assert session.errors.blank?
|
136
|
-
assert_equal user, session.
|
152
|
+
assert_equal user, session.object
|
137
153
|
assert_equal user, session.user
|
138
154
|
end
|
139
155
|
|
@@ -142,7 +158,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
142
158
|
admin = Admin.create!(:username => 'admin', :password => 'pass')
|
143
159
|
session = AdminSession.create(:username => admin.username, :password => 'pass')
|
144
160
|
assert session.errors.blank?
|
145
|
-
assert_equal admin, session.
|
161
|
+
assert_equal admin, session.object
|
146
162
|
assert_equal admin, session.admin
|
147
163
|
end
|
148
164
|
|
@@ -151,7 +167,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
151
167
|
session = UserSession.create(:email => user.email, :password => 'bad_pass')
|
152
168
|
assert session.errors.present?
|
153
169
|
assert_equal 'Failed to authenticate', session.errors[:base].first
|
154
|
-
assert_equal nil, session.
|
170
|
+
assert_equal nil, session.object
|
155
171
|
assert_equal nil, session.user
|
156
172
|
end
|
157
173
|
|
@@ -163,7 +179,7 @@ class LetMeInTest < Test::Unit::TestCase
|
|
163
179
|
rescue LetMeIn::Error => e
|
164
180
|
assert_equal 'Failed to authenticate', e.to_s
|
165
181
|
end
|
166
|
-
assert_equal nil, session.
|
182
|
+
assert_equal nil, session.object
|
167
183
|
end
|
168
184
|
|
169
185
|
def test_session_authentication_on_blank_object
|
@@ -174,6 +190,23 @@ class LetMeInTest < Test::Unit::TestCase
|
|
174
190
|
rescue LetMeIn::Error => e
|
175
191
|
assert_equal 'Failed to authenticate', e.to_s
|
176
192
|
end
|
177
|
-
assert_equal nil, session.
|
193
|
+
assert_equal nil, session.object
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_custom_open_session
|
197
|
+
user = User.create!(:email => 'test@test.test', :password => 'pass')
|
198
|
+
session = OpenSession.new(:email => 'test@test.test', :password => 'bad_pass')
|
199
|
+
assert session.invalid?
|
200
|
+
assert_equal 'Failed to authenticate', session.errors[:base].first
|
201
|
+
session = OpenSession.new(:email => 'test@test.test', :password => 'pass')
|
202
|
+
assert session.valid?
|
203
|
+
assert_equal user, session.user
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_custom_closed_session
|
207
|
+
user = User.create!(:email => 'test@test.test', :password => 'pass')
|
208
|
+
session = ClosedSession.new(:email => 'test@test.test', :password => 'pass')
|
209
|
+
assert session.invalid?
|
210
|
+
assert_equal 'You shall not pass test@test.test', session.errors[:base].first
|
178
211
|
end
|
179
212
|
end
|
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.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-09 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
-
requirement: &
|
17
|
+
requirement: &70224158884440 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70224158884440
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bcrypt-ruby
|
28
|
-
requirement: &
|
28
|
+
requirement: &70224158883640 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70224158883640
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &70224158882120 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70224158882120
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: jeweler
|
50
|
-
requirement: &
|
50
|
+
requirement: &70224158880380 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: 1.5.2
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70224158880380
|
59
59
|
description: minimalistic authentication
|
60
60
|
email: oleg@khabarov.ca
|
61
61
|
executables: []
|
@@ -64,6 +64,7 @@ extra_rdoc_files:
|
|
64
64
|
- LICENSE
|
65
65
|
- README.md
|
66
66
|
files:
|
67
|
+
- .travis.yml
|
67
68
|
- Gemfile
|
68
69
|
- Gemfile.lock
|
69
70
|
- LICENSE
|
@@ -89,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
90
|
version: '0'
|
90
91
|
segments:
|
91
92
|
- 0
|
92
|
-
hash:
|
93
|
+
hash: -1283525767596471732
|
93
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
95
|
none: false
|
95
96
|
requirements:
|