devise_token_auth 0.1.27 → 0.1.28.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/devise_token_auth/application_controller.rb +1 -1
- data/app/controllers/devise_token_auth/auth_controller.rb +31 -3
- data/lib/devise_token_auth/version.rb +1 -1
- data/test/controllers/devise_token_auth/auth_controller_test.rb +26 -0
- data/test/dummy/app/helpers/application_helper.rb +5 -5
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +825 -0
- data/test/dummy/log/test.log +22246 -0
- data/test/dummy/tmp/generators/app/controllers/application_controller.rb +8 -0
- data/test/dummy/tmp/generators/db/migrate/{20140902154716_devise_token_auth_create_users.rb → 20140910003405_devise_token_auth_create_users.rb} +0 -0
- metadata +8 -12
- data/test/dummy/tmp/generators/app/models/mang.rb +0 -3
- data/test/dummy/tmp/generators/config/routes.rb +0 -9
- data/test/dummy/tmp/generators/db/migrate/20140902154716_devise_token_auth_create_mangs.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b99f8dae62f960788af8b108ab370e420a54291
|
4
|
+
data.tar.gz: ddad0d672de28b386c09c2384bbec83d9acd5efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7dca0bf0da13694fd383a38052d6da35d376597dc649a218b04d984a74c56b71c2c299b6a72c8b923a0b240392f3233f64f10dae27139884e92934ec5288a51
|
7
|
+
data.tar.gz: 1bf8004bfc4de1e9d74ea228b97770f30a969f3606321868cb8bd573c87c10658c9e87db3e147ade029838ee019b25d94b014fc92fcdd0379fcc2a00f22bcf04
|
data/README.md
CHANGED
@@ -21,11 +21,9 @@ module DeviseTokenAuth
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def omniauth_success
|
24
|
-
# pull resource class from omniauth return
|
25
|
-
resource = request.env['omniauth.params']['resource_class'].constantize
|
26
24
|
|
27
25
|
# find or create user by provider and provider uid
|
28
|
-
@user =
|
26
|
+
@user = resource_name.where({
|
29
27
|
uid: auth_hash['uid'],
|
30
28
|
provider: auth_hash['provider']
|
31
29
|
}).first_or_initialize
|
@@ -61,6 +59,10 @@ module DeviseTokenAuth
|
|
61
59
|
email: auth_hash['info']['email']
|
62
60
|
})
|
63
61
|
|
62
|
+
# assign any additional (whitelisted) attributes
|
63
|
+
extra_params = whitelisted_params
|
64
|
+
@user.assign_attributes(extra_params) if extra_params
|
65
|
+
|
64
66
|
# don't send confirmation email!!!
|
65
67
|
@user.skip_confirmation!
|
66
68
|
|
@@ -84,6 +86,32 @@ module DeviseTokenAuth
|
|
84
86
|
request.env['omniauth.auth']
|
85
87
|
end
|
86
88
|
|
89
|
+
def whitelisted_params
|
90
|
+
whitelist = devise_parameter_sanitizer.for(:sign_up)
|
91
|
+
|
92
|
+
whitelist.inject({}){|coll, key|
|
93
|
+
param = request.env['omniauth.params'][key.to_s]
|
94
|
+
if param
|
95
|
+
coll[key] = param
|
96
|
+
end
|
97
|
+
coll
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
def devise_controller?
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
# pull resource class from omniauth return
|
106
|
+
def resource_name
|
107
|
+
request.env['omniauth.params']['resource_class'].constantize
|
108
|
+
end
|
109
|
+
|
110
|
+
# necessary for access to devise_parameter_sanitizers
|
111
|
+
def devise_mapping
|
112
|
+
Devise.mappings[request.env['omniauth.params']['resource_class'].underscore.to_sym]
|
113
|
+
end
|
114
|
+
|
87
115
|
def generate_url(url, params = {})
|
88
116
|
uri = URI(url)
|
89
117
|
uri.query = params.to_query
|
@@ -57,6 +57,32 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
57
57
|
assert_equal User, @user.class
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
describe 'pass additional params' do
|
62
|
+
before do
|
63
|
+
@fav_color = 'alizarin crimson'
|
64
|
+
@unpermitted_param = "M. Bison"
|
65
|
+
get_via_redirect '/auth/facebook', {
|
66
|
+
auth_origin_url: @redirect_url,
|
67
|
+
favorite_color: @fav_color,
|
68
|
+
name: @unpermitted_param
|
69
|
+
}
|
70
|
+
|
71
|
+
@user = assigns(:user)
|
72
|
+
end
|
73
|
+
|
74
|
+
test 'status shows success' do
|
75
|
+
assert_equal 200, response.status
|
76
|
+
end
|
77
|
+
|
78
|
+
test 'additional attribute was passed' do
|
79
|
+
assert_equal @fav_color, @user.favorite_color
|
80
|
+
end
|
81
|
+
|
82
|
+
test 'non-whitelisted attributes are ignored' do
|
83
|
+
refute_equal @unpermitted_param, @user.name
|
84
|
+
end
|
85
|
+
end
|
60
86
|
end
|
61
87
|
|
62
88
|
|
@@ -60,7 +60,7 @@ module ApplicationHelper
|
|
60
60
|
"Beaver",
|
61
61
|
"Beige",
|
62
62
|
"B'dazzled blue",
|
63
|
-
"Big dip o
|
63
|
+
"Big dip o'ruby",
|
64
64
|
"Bisque",
|
65
65
|
"Bistre",
|
66
66
|
"Bistre brown",
|
@@ -134,8 +134,8 @@ module ApplicationHelper
|
|
134
134
|
"Cadmium orange",
|
135
135
|
"Cadmium red",
|
136
136
|
"Cadmium yellow",
|
137
|
-
"
|
138
|
-
"
|
137
|
+
"Cafe au lait",
|
138
|
+
"Cafe noir",
|
139
139
|
"Cal Poly Pomona green",
|
140
140
|
"Cambridge Blue",
|
141
141
|
"Camel",
|
@@ -422,7 +422,7 @@ module ApplicationHelper
|
|
422
422
|
"Grizzly",
|
423
423
|
"Grullo",
|
424
424
|
"Guppie green",
|
425
|
-
"
|
425
|
+
"Halaya ube",
|
426
426
|
"Han blue",
|
427
427
|
"Han purple",
|
428
428
|
"Hansa yellow",
|
@@ -955,7 +955,7 @@ module ApplicationHelper
|
|
955
955
|
"Teal deer",
|
956
956
|
"Teal green",
|
957
957
|
"Telemagenta",
|
958
|
-
"
|
958
|
+
"Tenne",
|
959
959
|
"Terra cotta",
|
960
960
|
"Thistle",
|
961
961
|
"Thulian pink",
|
Binary file
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|