monban 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +60 -86
- data/lib/monban/configuration.rb +6 -1
- data/lib/monban/constraints/signed_in.rb +10 -0
- data/lib/monban/services/sign_up.rb +11 -3
- data/lib/monban/version.rb +1 -1
- data/lib/monban.rb +3 -2
- data/spec/features/visitor/visitor_fails_to_sign_up_spec.rb +1 -1
- data/spec/features/visitor/visitor_signs_in_via_invalid_form_spec.rb +11 -0
- data/spec/monban/services/sign_up_spec.rb +22 -1
- data/spec/rails_app/app/controllers/invalid_sessions_controller.rb +2 -0
- data/spec/rails_app/app/models/user.rb +4 -0
- data/spec/rails_app/app/views/invalid_sessions/new.html.erb +4 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +2 -0
- data/spec/rails_app/config/routes.rb +2 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aca082188020521eb26286f4329290137e03ee38
|
4
|
+
data.tar.gz: 9bfb518930ce8de955f38ebd44371645e1051324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e43239016ff07761fc2b870276033cbad7b16f4bb8dac62555f1bb5328be648d2ec74ec69c622d6ecec46bc8f9bbcc724f758b4f518ba10cafda1212bf6b3db
|
7
|
+
data.tar.gz: bccdc6fe8918d5b4ee34a9127fa591bb28617ff2b1cb786fe4ca8926746b72aa2800f73dd979d18677e4f96328a6145f41becccde90253266babf00760869db1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
monban (0.0.
|
4
|
+
monban (0.0.12)
|
5
5
|
bcrypt
|
6
6
|
rails
|
7
7
|
warden
|
@@ -9,38 +9,35 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionmailer (
|
13
|
-
actionpack (
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
actionmailer (0.6.1)
|
13
|
+
actionpack (>= 0.9.5)
|
14
|
+
actionpack (4.1.0)
|
15
|
+
actionview (= 4.1.0)
|
16
|
+
activesupport (= 4.1.0)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
actionview (4.1.0)
|
20
|
+
activesupport (= 4.1.0)
|
21
|
+
builder (~> 3.1)
|
19
22
|
erubis (~> 2.7.0)
|
20
|
-
journey (~> 1.0.4)
|
21
|
-
rack (~> 1.4.0)
|
22
|
-
rack-cache (~> 1.2)
|
23
|
-
rack-test (~> 0.6.1)
|
24
|
-
sprockets (~> 2.2.1)
|
25
23
|
active_hash (0.9.13)
|
26
24
|
activesupport (>= 2.2.2)
|
27
|
-
activemodel (
|
28
|
-
activesupport (=
|
29
|
-
builder (~> 3.
|
30
|
-
activerecord (
|
31
|
-
activemodel (=
|
32
|
-
activesupport (=
|
33
|
-
arel (~>
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
arel (3.0.3)
|
25
|
+
activemodel (4.1.0)
|
26
|
+
activesupport (= 4.1.0)
|
27
|
+
builder (~> 3.1)
|
28
|
+
activerecord (4.1.0)
|
29
|
+
activemodel (= 4.1.0)
|
30
|
+
activesupport (= 4.1.0)
|
31
|
+
arel (~> 5.0.0)
|
32
|
+
activesupport (4.1.0)
|
33
|
+
i18n (~> 0.6, >= 0.6.9)
|
34
|
+
json (~> 1.7, >= 1.7.7)
|
35
|
+
minitest (~> 5.1)
|
36
|
+
thread_safe (~> 0.1)
|
37
|
+
tzinfo (~> 1.1)
|
38
|
+
arel (5.0.1.20140414130214)
|
42
39
|
bcrypt (3.1.7)
|
43
|
-
builder (3.
|
40
|
+
builder (3.2.2)
|
44
41
|
capybara (2.0.2)
|
45
42
|
mime-types (>= 1.16)
|
46
43
|
nokogiri (>= 1.3.3)
|
@@ -50,79 +47,56 @@ GEM
|
|
50
47
|
xpath (~> 1.0.0)
|
51
48
|
childprocess (0.3.7)
|
52
49
|
ffi (~> 1.0, >= 1.0.6)
|
53
|
-
diff-lcs (1.
|
50
|
+
diff-lcs (1.2.5)
|
54
51
|
erubis (2.7.0)
|
55
52
|
ffi (1.3.1)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
i18n (>= 0.4.0)
|
62
|
-
mime-types (~> 1.16)
|
63
|
-
treetop (~> 1.4.8)
|
64
|
-
mime-types (1.20.1)
|
65
|
-
multi_json (1.5.0)
|
53
|
+
i18n (0.6.9)
|
54
|
+
json (1.8.1)
|
55
|
+
mime-types (2.2)
|
56
|
+
minitest (5.3.3)
|
57
|
+
multi_json (1.9.3)
|
66
58
|
nokogiri (1.5.6)
|
67
|
-
|
68
|
-
rack (1.4.4)
|
69
|
-
rack-cache (1.2)
|
70
|
-
rack (>= 0.4)
|
71
|
-
rack-ssl (1.3.3)
|
72
|
-
rack
|
59
|
+
rack (1.5.2)
|
73
60
|
rack-test (0.6.2)
|
74
61
|
rack (>= 1.0)
|
75
|
-
rails (
|
76
|
-
actionmailer (
|
77
|
-
actionpack (
|
78
|
-
activerecord (
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
railties (3.2.11)
|
84
|
-
actionpack (= 3.2.11)
|
85
|
-
activesupport (= 3.2.11)
|
86
|
-
rack-ssl (~> 1.3.2)
|
62
|
+
rails (0.9.5)
|
63
|
+
actionmailer (>= 0.6.1)
|
64
|
+
actionpack (>= 1.4.0)
|
65
|
+
activerecord (>= 1.6.0)
|
66
|
+
rake (>= 0.4.15)
|
67
|
+
railties (4.1.0)
|
68
|
+
actionpack (= 4.1.0)
|
69
|
+
activesupport (= 4.1.0)
|
87
70
|
rake (>= 0.8.7)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
rspec-
|
98
|
-
rspec-
|
99
|
-
diff-lcs (~> 1.1.3)
|
100
|
-
rspec-mocks (2.12.2)
|
101
|
-
rspec-rails (2.12.0)
|
71
|
+
thor (>= 0.18.1, < 2.0)
|
72
|
+
rake (10.3.1)
|
73
|
+
rspec (2.14.1)
|
74
|
+
rspec-core (~> 2.14.0)
|
75
|
+
rspec-expectations (~> 2.14.0)
|
76
|
+
rspec-mocks (~> 2.14.0)
|
77
|
+
rspec-core (2.14.8)
|
78
|
+
rspec-expectations (2.14.5)
|
79
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
80
|
+
rspec-mocks (2.14.6)
|
81
|
+
rspec-rails (2.14.2)
|
102
82
|
actionpack (>= 3.0)
|
83
|
+
activemodel (>= 3.0)
|
103
84
|
activesupport (>= 3.0)
|
104
85
|
railties (>= 3.0)
|
105
|
-
rspec-core (~> 2.
|
106
|
-
rspec-expectations (~> 2.
|
107
|
-
rspec-mocks (~> 2.
|
86
|
+
rspec-core (~> 2.14.0)
|
87
|
+
rspec-expectations (~> 2.14.0)
|
88
|
+
rspec-mocks (~> 2.14.0)
|
108
89
|
rubyzip (0.9.9)
|
109
90
|
selenium-webdriver (2.29.0)
|
110
91
|
childprocess (>= 0.2.5)
|
111
92
|
multi_json (~> 1.0)
|
112
93
|
rubyzip
|
113
94
|
websocket (~> 1.0.4)
|
114
|
-
sprockets (2.2.2)
|
115
|
-
hike (~> 1.2)
|
116
|
-
multi_json (~> 1.0)
|
117
|
-
rack (~> 1.0)
|
118
|
-
tilt (~> 1.1, != 1.3.0)
|
119
95
|
sqlite3 (1.3.7)
|
120
|
-
thor (0.
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
polyglot (>= 0.3.1)
|
125
|
-
tzinfo (0.3.39)
|
96
|
+
thor (0.19.1)
|
97
|
+
thread_safe (0.3.3)
|
98
|
+
tzinfo (1.1.0)
|
99
|
+
thread_safe (~> 0.1)
|
126
100
|
warden (1.2.3)
|
127
101
|
rack (>= 1.0)
|
128
102
|
websocket (1.0.7)
|
data/lib/monban/configuration.rb
CHANGED
@@ -7,7 +7,7 @@ module Monban
|
|
7
7
|
attr_accessor :sign_in_service, :sign_up_service, :sign_out_service
|
8
8
|
attr_accessor :authentication_service, :password_reset_service
|
9
9
|
attr_accessor :failure_app
|
10
|
-
attr_accessor :creation_method
|
10
|
+
attr_accessor :creation_method, :find_method
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
setup_class_defaults
|
@@ -25,6 +25,10 @@ module Monban
|
|
25
25
|
->(token) { BCrypt::Password.create(token) }
|
26
26
|
end
|
27
27
|
|
28
|
+
def default_find_method
|
29
|
+
->(params) { Monban.user_class.find_by(params) }
|
30
|
+
end
|
31
|
+
|
28
32
|
def default_password_comparison
|
29
33
|
->(digest, unencrypted_token) do
|
30
34
|
BCrypt::Password.new(digest) == unencrypted_token
|
@@ -48,6 +52,7 @@ module Monban
|
|
48
52
|
@user_token_store_field = :password_digest
|
49
53
|
@user_lookup_field = :email
|
50
54
|
@creation_method = default_creation_method
|
55
|
+
@find_method = default_find_method
|
51
56
|
end
|
52
57
|
|
53
58
|
def setup_services
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Monban
|
2
2
|
class SignUp
|
3
3
|
def initialize user_params
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
encrypted_token = token_digest(user_params)
|
5
|
+
@user_params = user_params.
|
6
|
+
except(token_field).
|
7
|
+
merge(token_store_field.to_sym => encrypted_token)
|
7
8
|
end
|
8
9
|
|
9
10
|
def perform
|
@@ -12,6 +13,13 @@ module Monban
|
|
12
13
|
|
13
14
|
private
|
14
15
|
|
16
|
+
def token_digest(user_params)
|
17
|
+
unencrypted_token = user_params[token_field]
|
18
|
+
unless unencrypted_token.empty?
|
19
|
+
Monban.encrypt_token(unencrypted_token)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
15
23
|
def token_store_field
|
16
24
|
Monban.config.user_token_store_field
|
17
25
|
end
|
data/lib/monban/version.rb
CHANGED
data/lib/monban.rb
CHANGED
@@ -37,7 +37,8 @@ module Monban
|
|
37
37
|
|
38
38
|
def self.lookup(params, field_map)
|
39
39
|
fields = FieldMap.new(params, field_map).to_fields
|
40
|
-
|
40
|
+
default_fields = { Monban.config.user_lookup_field => nil }
|
41
|
+
self.config.find_method.call(default_fields.merge(fields))
|
41
42
|
end
|
42
43
|
|
43
44
|
def self.test_mode!
|
@@ -50,7 +51,7 @@ module Monban
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def self.configure(&block)
|
53
|
-
self.config
|
54
|
+
self.config ||= Monban::Configuration.new
|
54
55
|
yield self.config
|
55
56
|
end
|
56
57
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Visitor signs in with invalid form' do
|
4
|
+
scenario 'is not signed in' do
|
5
|
+
Monban::SignUp.new(email: 'email@example.com', password: 'password').perform
|
6
|
+
visit invalid_sign_in_path
|
7
|
+
fill_in "session_password", with: 'password'
|
8
|
+
click_button 'go'
|
9
|
+
expect(page).to have_content("Sign in")
|
10
|
+
end
|
11
|
+
end
|
@@ -22,7 +22,28 @@ describe Monban::SignUp, '#perform' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
user_params = { email: 'email@example.com', password: 'password' }
|
25
|
-
|
25
|
+
swap_creation_method user_create_double do
|
26
|
+
Monban::SignUp.new(user_params).perform
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def swap_creation_method(new_creation_method, &block)
|
31
|
+
old_creation_method = Monban.config.creation_method
|
32
|
+
Monban.config.creation_method = new_creation_method
|
33
|
+
yield
|
34
|
+
ensure
|
35
|
+
Monban.config.creation_method = old_creation_method
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'does not create a user with an empty password' do
|
39
|
+
create = double
|
40
|
+
stub_const('User', create)
|
41
|
+
user_params = { email: 'email@example.com', password: '' }
|
42
|
+
|
43
|
+
create.should_receive(:create) do |args|
|
44
|
+
args[:password_digest].should be_nil
|
45
|
+
end
|
46
|
+
|
26
47
|
Monban::SignUp.new(user_params).perform
|
27
48
|
end
|
28
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- halogenandtoast
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/monban.rb
|
162
162
|
- lib/monban/back_door.rb
|
163
163
|
- lib/monban/configuration.rb
|
164
|
+
- lib/monban/constraints/signed_in.rb
|
164
165
|
- lib/monban/controller_helpers.rb
|
165
166
|
- lib/monban/field_map.rb
|
166
167
|
- lib/monban/railtie.rb
|
@@ -178,6 +179,7 @@ files:
|
|
178
179
|
- monban.gemspec
|
179
180
|
- spec/features/visitor/visitor_fails_to_sign_up_spec.rb
|
180
181
|
- spec/features/visitor/visitor_is_unauthorized_spec.rb
|
182
|
+
- spec/features/visitor/visitor_signs_in_via_invalid_form_spec.rb
|
181
183
|
- spec/features/visitor/visitor_signs_up_spec.rb
|
182
184
|
- spec/features/visitor/visitor_uses_remember_token_spec.rb
|
183
185
|
- spec/monban/controller_helpers_spec.rb
|
@@ -196,11 +198,13 @@ files:
|
|
196
198
|
- spec/rails_app/app/assets/stylesheets/application.css
|
197
199
|
- spec/rails_app/app/controllers/application_controller.rb
|
198
200
|
- spec/rails_app/app/controllers/failures_controller.rb
|
201
|
+
- spec/rails_app/app/controllers/invalid_sessions_controller.rb
|
199
202
|
- spec/rails_app/app/controllers/posts_controller.rb
|
200
203
|
- spec/rails_app/app/controllers/sessions_controller.rb
|
201
204
|
- spec/rails_app/app/controllers/users_controller.rb
|
202
205
|
- spec/rails_app/app/helpers/application_helper.rb
|
203
206
|
- spec/rails_app/app/models/user.rb
|
207
|
+
- spec/rails_app/app/views/invalid_sessions/new.html.erb
|
204
208
|
- spec/rails_app/app/views/layouts/application.html.erb
|
205
209
|
- spec/rails_app/app/views/posts/index.html.erb
|
206
210
|
- spec/rails_app/app/views/sessions/new.html.erb
|
@@ -251,6 +255,7 @@ summary: Making rails authentication as simple as possible
|
|
251
255
|
test_files:
|
252
256
|
- spec/features/visitor/visitor_fails_to_sign_up_spec.rb
|
253
257
|
- spec/features/visitor/visitor_is_unauthorized_spec.rb
|
258
|
+
- spec/features/visitor/visitor_signs_in_via_invalid_form_spec.rb
|
254
259
|
- spec/features/visitor/visitor_signs_up_spec.rb
|
255
260
|
- spec/features/visitor/visitor_uses_remember_token_spec.rb
|
256
261
|
- spec/monban/controller_helpers_spec.rb
|
@@ -269,11 +274,13 @@ test_files:
|
|
269
274
|
- spec/rails_app/app/assets/stylesheets/application.css
|
270
275
|
- spec/rails_app/app/controllers/application_controller.rb
|
271
276
|
- spec/rails_app/app/controllers/failures_controller.rb
|
277
|
+
- spec/rails_app/app/controllers/invalid_sessions_controller.rb
|
272
278
|
- spec/rails_app/app/controllers/posts_controller.rb
|
273
279
|
- spec/rails_app/app/controllers/sessions_controller.rb
|
274
280
|
- spec/rails_app/app/controllers/users_controller.rb
|
275
281
|
- spec/rails_app/app/helpers/application_helper.rb
|
276
282
|
- spec/rails_app/app/models/user.rb
|
283
|
+
- spec/rails_app/app/views/invalid_sessions/new.html.erb
|
277
284
|
- spec/rails_app/app/views/layouts/application.html.erb
|
278
285
|
- spec/rails_app/app/views/posts/index.html.erb
|
279
286
|
- spec/rails_app/app/views/sessions/new.html.erb
|