monban 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/NEWS.rdoc +4 -0
- data/lib/monban.rb +11 -0
- data/lib/monban/configuration.rb +3 -7
- data/lib/monban/controller_helpers.rb +6 -4
- data/lib/monban/version.rb +2 -2
- data/spec/features/user/user_signs_in_spec.rb +14 -0
- data/spec/features/visitor/visitor_signs_up_spec.rb +9 -0
- data/spec/spec_helper.rb +6 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a099fb20745246c9094ac5c9957119180cb452
|
4
|
+
data.tar.gz: 4f8aec070188cccfcb27c51692e2942dd67fafe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809a7eec54aa4327fd7c383088cd2a1a91cc53a4cc96eda43917f070a55c1b41986dce8bd58e7a6f3e0feefb42f25b119f31bf819ce4f07618693e536f0904f6
|
7
|
+
data.tar.gz: e7fc64a1393b18b6525962004143c3c82978c41fb4f0712c36186fccccb4da2675ec7db31a289742e33cef7ea1754c747e5ac9b9dcd26753f46dc0a78dbacc3d
|
data/NEWS.rdoc
CHANGED
data/lib/monban.rb
CHANGED
@@ -55,6 +55,17 @@ module Monban
|
|
55
55
|
config.hashing_method.call(token)
|
56
56
|
end
|
57
57
|
|
58
|
+
|
59
|
+
# performs transformations on params for signing up and
|
60
|
+
# signing in
|
61
|
+
#
|
62
|
+
# @param params [Hash] hash of parameters to transform
|
63
|
+
# @see Monban::Configuration#param_transofmrations
|
64
|
+
# @return [Hash] hash with transformed parameters
|
65
|
+
def self.transform_params(params)
|
66
|
+
ParamTransformer.new(params, config.param_transformations).to_h
|
67
|
+
end
|
68
|
+
|
58
69
|
# the user class
|
59
70
|
#
|
60
71
|
# @see Monban::Configuration#setup_class_defaults
|
data/lib/monban/configuration.rb
CHANGED
@@ -30,7 +30,7 @@ module Monban
|
|
30
30
|
# @see #creation_method=
|
31
31
|
def default_creation_method
|
32
32
|
->(params) do
|
33
|
-
updated_params = transform_params(params)
|
33
|
+
updated_params = Monban.transform_params(params)
|
34
34
|
Monban.config.user_class.create(updated_params)
|
35
35
|
end
|
36
36
|
end
|
@@ -54,7 +54,7 @@ module Monban
|
|
54
54
|
# @see Monban.config.user_class
|
55
55
|
def default_find_method
|
56
56
|
->(params) do
|
57
|
-
updated_params = transform_params(params)
|
57
|
+
updated_params = Monban.transform_params(params)
|
58
58
|
Monban.config.user_class.find_by(updated_params)
|
59
59
|
end
|
60
60
|
end
|
@@ -134,12 +134,8 @@ module Monban
|
|
134
134
|
|
135
135
|
def setup_param_transformations
|
136
136
|
@param_transformations = {
|
137
|
-
email
|
137
|
+
"email" => ->(value) { value.downcase }
|
138
138
|
}
|
139
139
|
end
|
140
|
-
|
141
|
-
def transform_params(params)
|
142
|
-
ParamTransformer.new(params, param_transformations).to_h
|
143
|
-
end
|
144
140
|
end
|
145
141
|
end
|
@@ -7,7 +7,9 @@ module Monban
|
|
7
7
|
module ControllerHelpers
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
included do
|
10
|
-
|
10
|
+
if respond_to?(:helper_method)
|
11
|
+
helper_method :current_user, :signed_in?
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
# Sign in a user
|
@@ -98,9 +100,9 @@ module Monban
|
|
98
100
|
|
99
101
|
def authenticate_session session_params, field_map = nil
|
100
102
|
token_field = Monban.config.user_token_field
|
101
|
-
|
102
|
-
password =
|
103
|
-
user = Monban.lookup(
|
103
|
+
params_hash = Monban.transform_params(session_params).symbolize_keys
|
104
|
+
password = params_hash.fetch(token_field)
|
105
|
+
user = Monban.lookup(params_hash.except(token_field), field_map)
|
104
106
|
authenticate(user, password)
|
105
107
|
end
|
106
108
|
|
data/lib/monban/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'User signs in' do
|
4
|
+
scenario 'with mismatched email case' do
|
5
|
+
user = User.create!(email: "example@example.com", password_digest: "password")
|
6
|
+
|
7
|
+
visit sign_in_path
|
8
|
+
fill_in "session[email]", with: "Example@example.com"
|
9
|
+
fill_in "session[password]", with: "password"
|
10
|
+
click_button "go"
|
11
|
+
|
12
|
+
expect(current_path).to eq posts_path
|
13
|
+
end
|
14
|
+
end
|
@@ -10,6 +10,15 @@ feature 'Visitor signs up' do
|
|
10
10
|
expect(page.current_path).to eq(posts_path)
|
11
11
|
end
|
12
12
|
|
13
|
+
scenario 'with uppercase email' do
|
14
|
+
visit sign_up_path
|
15
|
+
fill_in 'user_email', with: 'Email@example.com'
|
16
|
+
fill_in 'user_password', with: 'password'
|
17
|
+
click_on 'go'
|
18
|
+
|
19
|
+
expect(User.last.email).to eq('email@example.com')
|
20
|
+
end
|
21
|
+
|
13
22
|
scenario 'multiple users' do
|
14
23
|
visit sign_up_path
|
15
24
|
fill_in 'user_email', with: 'email@example.com'
|
data/spec/spec_helper.rb
CHANGED
@@ -7,10 +7,16 @@ require 'warden'
|
|
7
7
|
require 'monban'
|
8
8
|
require 'capybara'
|
9
9
|
|
10
|
+
Monban.test_mode!
|
11
|
+
Warden.test_mode!
|
12
|
+
|
10
13
|
RSpec.configure do |config|
|
11
14
|
config.include Warden::Test::Helpers
|
12
15
|
config.include Monban::Test::Helpers, type: :feature
|
13
16
|
config.order = "random"
|
17
|
+
config.after :each do
|
18
|
+
Monban.test_reset!
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
def with_monban_config(hash, &block)
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2016-
|
12
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/monban/version.rb
|
176
176
|
- lib/monban/warden_setup.rb
|
177
177
|
- monban.gemspec
|
178
|
+
- spec/features/user/user_signs_in_spec.rb
|
178
179
|
- spec/features/user/user_signs_in_through_back_door_spec.rb
|
179
180
|
- spec/features/user/user_tries_to_access_constrained_routes_spec.rb
|
180
181
|
- spec/features/user/user_tries_to_access_http_auth_page_spec.rb
|
@@ -260,6 +261,7 @@ signing_key:
|
|
260
261
|
specification_version: 4
|
261
262
|
summary: Making rails authentication as simple as possible
|
262
263
|
test_files:
|
264
|
+
- spec/features/user/user_signs_in_spec.rb
|
263
265
|
- spec/features/user/user_signs_in_through_back_door_spec.rb
|
264
266
|
- spec/features/user/user_tries_to_access_constrained_routes_spec.rb
|
265
267
|
- spec/features/user/user_tries_to_access_http_auth_page_spec.rb
|