sync_attr_with_auth0 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78b6cc16ee90ef4923134f94be42fd6f9f5507a04f76855d53fbaed46d6f780f
|
4
|
+
data.tar.gz: 07ac9b9cc8ee2e07a21bae95964a082e5c2a6fd5bc8db63e3721b97b2d2a8e6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '01239ff7161e9a1f6787b7e41161c9edf354463168af54cd941f5ede9172cf68ed4ad053edeea662e2411381d696362c8e014521d9ea63b056fec57837f8cfea'
|
7
|
+
data.tar.gz: '09dba8dcf96b0b8dd28bec491bb372ded1d53f426837e664b5d462aaf9ea524e301b22009eccb86af16c38bb67d8bb3503e2a2f3340d9a90e96a147fd4e5eb34'
|
@@ -94,11 +94,12 @@ module SyncAttrWithAuth0
|
|
94
94
|
def create_in_auth0
|
95
95
|
params = auth0_create_params
|
96
96
|
|
97
|
-
response = SyncAttrWithAuth0::Auth0.create_user(
|
97
|
+
response = SyncAttrWithAuth0::Auth0.create_user(params, config: auth0_sync_configuration)
|
98
98
|
|
99
|
-
# Update the record with the uid and picture
|
100
|
-
|
101
|
-
|
99
|
+
# Update the record with the uid and picture
|
100
|
+
auth0_uid = response['user_id']
|
101
|
+
auth0_picture = response['picture']
|
102
|
+
update_uid_and_picture_from_auth0 auth0_uid, auth0_picture
|
102
103
|
end # create_in_auth0
|
103
104
|
|
104
105
|
|
@@ -109,8 +110,9 @@ module SyncAttrWithAuth0
|
|
109
110
|
response = SyncAttrWithAuth0::Auth0.patch_user(user_uid, auth0_update_params(user_uid), config: auth0_sync_configuration)
|
110
111
|
|
111
112
|
# Update the record with the uid after_commit (in case it doesn't match what's on file).
|
112
|
-
|
113
|
-
|
113
|
+
auth0_uid = user_uid
|
114
|
+
auth0_picture = response['picture']
|
115
|
+
update_uid_and_picture_from_auth0 auth0_uid, auth0_picture
|
114
116
|
rescue ::Auth0::NotFound => e
|
115
117
|
# For whatever reason, the passed in uid was invalid,
|
116
118
|
# determine how to proceed.
|
@@ -125,9 +127,10 @@ module SyncAttrWithAuth0
|
|
125
127
|
# and update the one on file.
|
126
128
|
response = SyncAttrWithAuth0::Auth0.patch_user(found_user['user_id'], auth0_update_params(found_user['user_id']), config: auth0_sync_configuration)
|
127
129
|
|
128
|
-
# Update the record with the uid
|
129
|
-
|
130
|
-
|
130
|
+
# Update the record with the uid
|
131
|
+
auth0_uid = found_user['user_id']
|
132
|
+
auth0_picture = response['picture']
|
133
|
+
update_uid_and_picture_from_auth0 auth0_uid, auth0_picture
|
131
134
|
end
|
132
135
|
|
133
136
|
rescue Exception => e
|
@@ -203,25 +206,20 @@ module SyncAttrWithAuth0
|
|
203
206
|
end # auth0_update_params
|
204
207
|
|
205
208
|
|
206
|
-
def update_uid_and_picture_from_auth0
|
209
|
+
def update_uid_and_picture_from_auth0(auth0_uid, auth0_picture)
|
207
210
|
data = {}
|
208
211
|
|
209
|
-
if
|
212
|
+
if auth0_uid
|
210
213
|
attr = auth0_sync_configuration.auth0_uid_attribute
|
211
|
-
data[attr] =
|
214
|
+
data[attr] = auth0_uid if respond_to?(attr) && auth0_uid != public_send(attr)
|
212
215
|
end
|
213
216
|
|
214
|
-
if
|
217
|
+
if auth0_picture
|
215
218
|
attr = auth0_sync_configuration.picture_attribute
|
216
|
-
data[attr] =
|
219
|
+
data[attr] = auth0_picture if respond_to?(attr) && auth0_picture != public_send(attr)
|
217
220
|
end
|
218
221
|
|
219
222
|
update_columns data unless data.empty?
|
220
|
-
|
221
|
-
remove_instance_variable :@auth0_uid if defined? @auth0_uid
|
222
|
-
remove_instance_variable :@auth0_picture if defined? @auth0_picture
|
223
|
-
|
224
|
-
true # don't abort the callback chain
|
225
223
|
end # update_uid_and_picture_from_auth0
|
226
224
|
|
227
225
|
end
|
@@ -36,7 +36,6 @@ module SyncAttrWithAuth0
|
|
36
36
|
after_validation :validate_email_with_auth0
|
37
37
|
after_create :save_to_auth0_after_create
|
38
38
|
after_update :save_to_auth0_after_update
|
39
|
-
after_commit :update_uid_and_picture_from_auth0
|
40
39
|
end # sync_attr_with_auth0
|
41
40
|
|
42
41
|
end # ClassMethods
|
@@ -17,7 +17,7 @@ module SyncAttrWithAuth0
|
|
17
17
|
'jti' => UUIDTools::UUID.random_create.to_s
|
18
18
|
}
|
19
19
|
|
20
|
-
jwt = JWT.encode(payload, JWT.
|
20
|
+
jwt = JWT.encode(payload, JWT::Base64.url_decode(global_client_secret), 'HS256', { typ: 'JWT' })
|
21
21
|
|
22
22
|
return jwt
|
23
23
|
end # ::create_auth0_jwt
|
@@ -86,10 +86,9 @@ module SyncAttrWithAuth0
|
|
86
86
|
end # ::find_users_by_email
|
87
87
|
|
88
88
|
|
89
|
-
def self.create_user(
|
89
|
+
def self.create_user(params, config: SyncAttrWithAuth0.configuration)
|
90
90
|
auth0 = SyncAttrWithAuth0::Auth0.create_auth0_client(config: config)
|
91
|
-
|
92
|
-
return auth0.create_user(name, params)
|
91
|
+
return auth0.create_user(params.delete('connection'), params)
|
93
92
|
end # ::create_user
|
94
93
|
|
95
94
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sync_attr_with_auth0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick McGraw
|
8
8
|
- Mike Oliver
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2016-07-26 00:00:00.000000000 Z
|
@@ -71,44 +71,44 @@ dependencies:
|
|
71
71
|
name: uuidtools
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: auth0
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: 5.0.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: 5.0.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: jwt
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
104
|
+
version: 2.2.0
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - "
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
111
|
+
version: 2.2.0
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: rails
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,16 +127,16 @@ dependencies:
|
|
127
127
|
name: rspec-rails
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
132
|
+
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - "
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
139
|
+
version: '0'
|
140
140
|
description: Synchronize attributes on a local ActiveRecord user model with the user
|
141
141
|
metadata store on Auth0
|
142
142
|
email: patrick@mcgraw-tech.com
|
@@ -154,7 +154,7 @@ homepage: http://rubygems.org/gems/sync_attr_with_auth0
|
|
154
154
|
licenses:
|
155
155
|
- MIT
|
156
156
|
metadata: {}
|
157
|
-
post_install_message:
|
157
|
+
post_install_message:
|
158
158
|
rdoc_options: []
|
159
159
|
require_paths:
|
160
160
|
- lib
|
@@ -169,8 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
173
|
-
signing_key:
|
172
|
+
rubygems_version: 3.4.19
|
173
|
+
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: Synchronize attributes on a local ActiveRecord user model with the user metadata
|
176
176
|
store on Auth0
|