sync_attr_with_auth0 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sync_attr_with_auth0/model.rb +20 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2bf2d9667067ee4ddf2b3a0f6984d4f6dbd1718
|
4
|
+
data.tar.gz: 2987a1a6425a37450e8f23f853ab651c9fa1d289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbe5201cad579b763012e6e72f1916f9465ff7c31d82857887e01ac57778685bd553f8239bc6d325bac879c9a20458c73df05295c072300ab915bdc8c7a49c3
|
7
|
+
data.tar.gz: 502b60f1108226edb88c752139b8ecda5816e28109b563d616d33444b7b9c840f99fb28cfc10a43c7ceab2ab5775c044430cb358082af3f022bb8c533c503dd3
|
@@ -15,6 +15,7 @@ module SyncAttrWithAuth0
|
|
15
15
|
after_validation :validate_email_with_auth0
|
16
16
|
after_create :auth0_create
|
17
17
|
after_update :auth0_update, if: :auth0_dirty?
|
18
|
+
after_commit :auth0_set_uid
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -106,6 +107,21 @@ module SyncAttrWithAuth0
|
|
106
107
|
true # don't abort the callback chain
|
107
108
|
end
|
108
109
|
|
110
|
+
def auth0_set_uid
|
111
|
+
if @auth0_uid
|
112
|
+
self.sync_with_auth0_on_update = false if self.respond_to?(:sync_with_auth0_on_update=)
|
113
|
+
self.send("#{auth0_sync_options[:uid_att]}=", @auth0_uid)
|
114
|
+
|
115
|
+
# Nil the instance variable to prevent an infinite loop
|
116
|
+
@auth0_uid = nil
|
117
|
+
|
118
|
+
# Save!
|
119
|
+
self.save
|
120
|
+
end
|
121
|
+
|
122
|
+
true # don't abort the callback chain
|
123
|
+
end
|
124
|
+
|
109
125
|
def create_user_in_auth0()
|
110
126
|
user_metadata = auth0_user_metadata
|
111
127
|
|
@@ -128,9 +144,8 @@ module SyncAttrWithAuth0
|
|
128
144
|
|
129
145
|
response = auth0.create_user(self.send(auth0_sync_options[:name_att]), args)
|
130
146
|
|
131
|
-
# Update the record with the uid
|
132
|
-
|
133
|
-
self.save
|
147
|
+
# Update the record with the uid after_commit
|
148
|
+
@auth0_uid = response['user_id']
|
134
149
|
end
|
135
150
|
|
136
151
|
def update_user_in_auth0(uid)
|
@@ -173,8 +188,8 @@ module SyncAttrWithAuth0
|
|
173
188
|
auth0 = SyncAttrWithAuth0::Auth0.create_auth0_client
|
174
189
|
auth0.patch_user(found_user['user_id'], args)
|
175
190
|
|
176
|
-
|
177
|
-
|
191
|
+
# Update the record with the uid after_commit
|
192
|
+
@auth0_uid = found_user['user_id']
|
178
193
|
end
|
179
194
|
|
180
195
|
rescue Exception => e
|