sync_attr_with_auth0 0.2.3 → 0.2.5

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: 74034877aaacaa02b288eed5519dc03fc80cc532e5af74805f0ea3b54d9c28ff
4
- data.tar.gz: a17973158b0ba5a922a415bb9bf7bde219a6e8a747785fb4b4ed455b2de4d660
3
+ metadata.gz: c2441467a77240b5be6d8fe7f33dfa57b5b3521945606c47803f928124b3b70f
4
+ data.tar.gz: 0231f6a6f5864485447a81c3c7e2c9e49beeb3d8def264e23f3a2cf5d863e7d6
5
5
  SHA512:
6
- metadata.gz: 1e68abd1b794812316737cd2b8d9372f64a857baa328233f79a4b448eae817a05e631a385c315a10dd1a3189ed17a316e868043b65d0aba39c2799491a4a53ed
7
- data.tar.gz: e25ba3a2b7256ac2915eb406eac60ea0a9ad81ea98c11bbb28366ec77d53fb79bd59156485b690d0496217e09ea3769d1834645401f9d981b084f06a0d18d82b
6
+ metadata.gz: 15b3328e06d33cc34c39e4367b41ebfb13475679c3f9c4137c9a996b6a450396bfef27921b5ae7c29780af36cceeb92612a706e63f7043a01eae8b8f00174ca4
7
+ data.tar.gz: 40381d9b91a763b6a7722ce7da08192d0008eeb0bef7329129e473a977808e0cb7538df22ed061945e67ff5dc207cec5572c2c473f33e01484ed1f2e634f8d93
@@ -105,10 +105,8 @@ module SyncAttrWithAuth0
105
105
  def update_in_auth0(user_uid)
106
106
  return unless user_uid
107
107
 
108
- params = auth0_update_params
109
-
110
108
  begin
111
- response = SyncAttrWithAuth0::Auth0.patch_user(user_uid, params, config: auth0_sync_configuration)
109
+ response = SyncAttrWithAuth0::Auth0.patch_user(user_uid, auth0_update_params(user_uid), config: auth0_sync_configuration)
112
110
 
113
111
  # Update the record with the uid after_commit (in case it doesn't match what's on file).
114
112
  @auth0_uid = user_uid
@@ -125,7 +123,7 @@ module SyncAttrWithAuth0
125
123
  else
126
124
  # The uid was incorrect, so re-attempt with the new uid
127
125
  # and update the one on file.
128
- response = SyncAttrWithAuth0::Auth0.patch_user(found_user['user_id'], params, config: auth0_sync_configuration)
126
+ response = SyncAttrWithAuth0::Auth0.patch_user(found_user['user_id'], auth0_update_params(found_user['user_id']), config: auth0_sync_configuration)
129
127
 
130
128
  # Update the record with the uid after_commit
131
129
  @auth0_uid = found_user['user_id']
@@ -171,19 +169,24 @@ module SyncAttrWithAuth0
171
169
  end # auth0_create_params
172
170
 
173
171
 
174
- def auth0_update_params
172
+ def auth0_update_params(user_uid)
175
173
  user_metadata = auth0_user_metadata
176
174
  app_metadata = auth0_app_metadata
175
+ is_auth0_connection_strategy = user_uid.start_with?("auth0|")
177
176
 
178
177
  params = {
179
- 'name' => auth0_user_name,
180
- 'nickname' => auth0_user_name,
181
- 'given_name' => auth0_user_given_name,
182
- 'family_name' => auth0_user_family_name,
183
178
  'app_metadata' => app_metadata,
184
179
  'user_metadata' => user_metadata
185
180
  }
186
181
 
182
+ if is_auth0_connection_strategy
183
+ # We can update the name attributes on Auth0 connection strategy only.
184
+ params['name'] = auth0_user_name
185
+ params['nickname'] = auth0_user_name
186
+ params['given_name'] = auth0_user_given_name
187
+ params['family_name'] = auth0_user_family_name
188
+ end
189
+
187
190
  if auth0_user_saved_change_to_password?
188
191
  # The password needs to be updated.
189
192
  params['password'] = auth0_user_password
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sync_attr_with_auth0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick McGraw