sync_attr_with_auth0 0.2.6 → 0.2.8

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: 3b29ebf79d97e921bb5e8cb4f8faed85f37d626e6637a3ade34a4e551d7e005a
4
- data.tar.gz: b1f528e810d6c6eb2eee5f2381f1ba1d337f1c83ced7c4ed63d795eb7fa8e804
3
+ metadata.gz: bdf5a4a8368fa7335d28196d46835cee80aadf6d05f91ac63f9107fcaaa7c5f5
4
+ data.tar.gz: e21784a081b09253de3252917f78c3cd0879f023f7344ffa158d45ccd0359cf7
5
5
  SHA512:
6
- metadata.gz: 86e479e00c7f1e86cb2b02b8e1a3fc7b922e04d05cf750b1e233f39462cf2ae98e2d8810e6d706fc872bbd9a6704eb23ae3963b3eb4f42c581bb2d06f03d7c75
7
- data.tar.gz: 1152e5d70a71e5e5cd4b208a6bafa39e788e6c4f03661aacd41d5497648008dcee15114bdf01f362f63a9be4472d73109be0f083f5bd40dd95bcd7ac0b354f5c
6
+ metadata.gz: ebea0eec3ca9f5f26b2131ae6653d0f14754d024893492e7ba9ee40c5a06d94b2d59245f841a8f61c52dcd30c089ddea7c5512810e33cfe4111a423c6cb8e5cd
7
+ data.tar.gz: e24bbed4725a05b7a506b290da5889edd1ba63e6d3af8086f06c4461e41a8996a391df0800dd323bbfb8392401aa54fb25418b59961648041834017109692ff5
@@ -96,9 +96,10 @@ module SyncAttrWithAuth0
96
96
 
97
97
  response = SyncAttrWithAuth0::Auth0.create_user(params, config: auth0_sync_configuration)
98
98
 
99
- # Update the record with the uid and picture after_commit
100
- @auth0_uid = response['user_id']
101
- @auth0_picture = response['picture']
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
- @auth0_uid = user_uid
113
- @auth0_picture = response['picture']
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 after_commit
129
- @auth0_uid = found_user['user_id']
130
- @auth0_picture = response['picture']
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 @auth0_uid
212
+ if auth0_uid
210
213
  attr = auth0_sync_configuration.auth0_uid_attribute
211
- data[attr] = @auth0_uid if respond_to?(attr) && @auth0_uid != public_send(attr)
214
+ data[attr] = auth0_uid if respond_to?(attr) && auth0_uid != public_send(attr)
212
215
  end
213
216
 
214
- if @auth0_picture
217
+ if auth0_picture
215
218
  attr = auth0_sync_configuration.picture_attribute
216
- data[attr] = @auth0_picture if respond_to?(attr) && @auth0_picture != public_send(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::Base64.url_decode(global_client_secret), 'HS256', { typ: 'JWT' })
20
+ jwt = JWT.encode(payload, JWT::Base64.url_decode(global_client_secret), 'RS256', { typ: 'JWT' })
21
21
 
22
22
  return jwt
23
23
  end # ::create_auth0_jwt
metadata CHANGED
@@ -1,11 +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.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick McGraw
8
8
  - Mike Oliver
9
+ - Eric Anderson
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
@@ -71,16 +72,16 @@ dependencies:
71
72
  name: uuidtools
72
73
  requirement: !ruby/object:Gem::Requirement
73
74
  requirements:
74
- - - '='
75
+ - - ">="
75
76
  - !ruby/object:Gem::Version
76
- version: 2.1.5
77
+ version: '0'
77
78
  type: :runtime
78
79
  prerelease: false
79
80
  version_requirements: !ruby/object:Gem::Requirement
80
81
  requirements:
81
- - - '='
82
+ - - ">="
82
83
  - !ruby/object:Gem::Version
83
- version: 2.1.5
84
+ version: '0'
84
85
  - !ruby/object:Gem::Dependency
85
86
  name: auth0
86
87
  requirement: !ruby/object:Gem::Requirement
@@ -127,16 +128,16 @@ dependencies:
127
128
  name: rspec-rails
128
129
  requirement: !ruby/object:Gem::Requirement
129
130
  requirements:
130
- - - "~>"
131
+ - - ">="
131
132
  - !ruby/object:Gem::Version
132
- version: '3.0'
133
+ version: '0'
133
134
  type: :development
134
135
  prerelease: false
135
136
  version_requirements: !ruby/object:Gem::Requirement
136
137
  requirements:
137
- - - "~>"
138
+ - - ">="
138
139
  - !ruby/object:Gem::Version
139
- version: '3.0'
140
+ version: '0'
140
141
  description: Synchronize attributes on a local ActiveRecord user model with the user
141
142
  metadata store on Auth0
142
143
  email: patrick@mcgraw-tech.com
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  - !ruby/object:Gem::Version
170
171
  version: '0'
171
172
  requirements: []
172
- rubygems_version: 3.0.6
173
+ rubygems_version: 3.1.4
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: Synchronize attributes on a local ActiveRecord user model with the user metadata