sync_attr_with_auth0 0.0.21 → 0.0.22

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
  SHA1:
3
- metadata.gz: e79727fa97e9f637b4e9922291ebb92de96d0678
4
- data.tar.gz: 9e5c0a922d5d3b8a3f15b5da66f98090978d56d7
3
+ metadata.gz: c7788c4f5abc0773865898d924dc408dcec79679
4
+ data.tar.gz: f72a93fd6f27bc23a93cf35ceacbf454ed1a3948
5
5
  SHA512:
6
- metadata.gz: fe728e2b3be857226ededc06b5f42b6b1161a4cfed6732e599ddda97664f73c94b2a2d3743b858a2a8e5a7c2cd55cc21d23bf2a0318220054193f4d6bd55e06e
7
- data.tar.gz: de2c6b0565dbb707f68894e3207d65661b9fa2a17cb5bd1c67da92de48d465bc969b547d441a04b59fddf6b4ec60802785c5707dad7c9e64e5af8f6c3498cda9
6
+ metadata.gz: 6bfad2038da2670a9d7f1f20868d397198bd1291f3413bc889adb2b082c661a8d2fffbb647c4ab8a7cc6db322e24b6673576b04896afb647cdd6642beaa4286f
7
+ data.tar.gz: 6a139dfb402e6e7227b19d8afb2aad3098100ebc7a1193ea01df6e52fa44fb48a161a2e5acbc25e831a55cedf6e54b596bf2476c750f537cf9893cc385af43c8
@@ -149,12 +149,7 @@ module SyncAttrWithAuth0
149
149
 
150
150
  if (
151
151
  auth0_sync_options[:sync_atts].index(auth0_sync_options[:password_att]) and
152
- # Because the password being passed to auth0 probably is not a real
153
- # field (and if it is it needs to be the unencrypted value), we
154
- # can't rely on checking if the password attribute changed (chances
155
- # are, that method does not exist). So assume the password attribute
156
- # is only set if it's being changed.
157
- !self.send(auth0_sync_options[:password_att]).nil?
152
+ auth0_user_password_changed?
158
153
  )
159
154
  # The password should be sync'd and was changed
160
155
  args['password'] = self.send(auth0_sync_options[:password_att])
@@ -202,6 +197,20 @@ module SyncAttrWithAuth0
202
197
  self.respond_to?(auth0_sync_options[:password_att]) ? self.send(auth0_sync_options[:password_att]) : auth0_default_password
203
198
  end
204
199
 
200
+ def auth0_user_password_changed?
201
+ if self.respond_to?(auth0_sync_options[:password_att])
202
+ if self.respond_to?(:"#{auth0_sync_options[:password_att].to_s}_changed?")
203
+ # We have a changed method, use it
204
+ return self.send(:"#{auth0_sync_options[:password_att].to_s}_changed?")
205
+ else
206
+ # We don't have a changed method, check if the attribute was set.
207
+ return !self.send(auth0_sync_options[:password_att]).nil?
208
+ end
209
+ end
210
+
211
+ return false
212
+ end
213
+
205
214
  def auth0_email_verified?
206
215
  !!(self.respond_to?(auth0_sync_options[:email_verified_att]) ? self.send(auth0_sync_options[:email_verified_att]) : false)
207
216
  end
@@ -234,9 +243,14 @@ module SyncAttrWithAuth0
234
243
  end
235
244
 
236
245
  def auth0_dirty?
237
- !!(auth0_sync_options[:sync_atts].inject(false) do |memo, attrib|
246
+ is_dirty = !!(auth0_sync_options[:sync_atts].inject(false) do |memo, attrib|
238
247
  memo || try("#{attrib}_changed?")
239
248
  end)
249
+
250
+ # If the password was changed, force is_dirty to be true
251
+ is_dirty = true if auth0_user_password_changed?
252
+
253
+ return is_dirty
240
254
  end
241
255
 
242
256
  end
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.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick McGraw
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  requirements: []
169
169
  rubyforge_project:
170
- rubygems_version: 2.4.5
170
+ rubygems_version: 2.4.6
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Synchronize attributes on a local ActiveRecord user model with the user metadata