sync_attr_with_auth0 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sync_attr_with_auth0/model.rb +31 -3
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8523e6aed514159fa1647e3d21b93da28db42acd
|
4
|
+
data.tar.gz: 2365c7f979670b45a6922718549e5da98550a92d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0542476a75202adf9f51aaabe90affbea46eb24022d8a18561eebffb3eb16e19b97f28f4180d3b6cf8ac32e1439d68e87474264276b9dd614cf54f3dcbe18dcc
|
7
|
+
data.tar.gz: a204c9d2fccbce726665fce6f860b37fc30d616bc39fc6ff6048650eb053aad2c7a102962d9e75b704bad462a48807476a1b92788d4abdc8c7f6bdba076bc5d4
|
@@ -2,6 +2,8 @@ module SyncAttrWithAuth0
|
|
2
2
|
module Model
|
3
3
|
extend ::ActiveSupport::Concern
|
4
4
|
|
5
|
+
require "uuidtools"
|
6
|
+
|
5
7
|
module ClassMethods
|
6
8
|
|
7
9
|
def sync_attr_with_auth0(options = {})
|
@@ -82,7 +84,7 @@ module SyncAttrWithAuth0
|
|
82
84
|
# Figure out what needs to be sent to Auth0
|
83
85
|
changes = {}
|
84
86
|
matches.each do |m|
|
85
|
-
changes[m] = self.send(m)
|
87
|
+
changes[m] = self.send(m) if self.respond_to?(m)
|
86
88
|
end
|
87
89
|
|
88
90
|
unless changes['email'].nil?
|
@@ -95,15 +97,18 @@ module SyncAttrWithAuth0
|
|
95
97
|
changes.delete('password')
|
96
98
|
end
|
97
99
|
|
100
|
+
password = auth0_user_password
|
101
|
+
email_verified = auth0_email_verified?
|
102
|
+
|
98
103
|
response = SyncAttrWithAuth0::Auth0.make_request(
|
99
104
|
access_token,
|
100
105
|
'post',
|
101
106
|
"/api/users",
|
102
107
|
{
|
103
108
|
'email' => self.send(email_att),
|
104
|
-
'password' =>
|
109
|
+
'password' => password,
|
105
110
|
'connection' => connection_name,
|
106
|
-
'email_verified' =>
|
111
|
+
'email_verified' => email_verified
|
107
112
|
}.merge(changes))
|
108
113
|
|
109
114
|
response = JSON.parse(response)
|
@@ -155,6 +160,12 @@ module SyncAttrWithAuth0
|
|
155
160
|
'email' => email,
|
156
161
|
'verify' => false # If the user were to fail to verify it would create a discrepency between auth0 and the local database
|
157
162
|
})
|
163
|
+
|
164
|
+
response = JSON.parse(response)
|
165
|
+
|
166
|
+
# Update the record with the uid
|
167
|
+
self.send("#{uid_att}=", response['user_id'])
|
168
|
+
self.save
|
158
169
|
end
|
159
170
|
|
160
171
|
# Determine if the password was changed
|
@@ -187,5 +198,22 @@ module SyncAttrWithAuth0
|
|
187
198
|
true # don't abort the callback chain
|
188
199
|
end
|
189
200
|
|
201
|
+
def auth0_user_password
|
202
|
+
self.respond_to?(password_att) ? self.send(password_att) : auth0_default_password
|
203
|
+
end
|
204
|
+
|
205
|
+
def auth0_email_verified?
|
206
|
+
self.respond_to?(email_verified_att) ? self.send(email_verified_att) : false
|
207
|
+
end
|
208
|
+
|
209
|
+
def auth0_default_password
|
210
|
+
# Need a9 or something similar to guarantee one letter and one number in the password
|
211
|
+
"#{auth0_new_uuid[0..19]}a9"
|
212
|
+
end
|
213
|
+
|
214
|
+
def auth0_new_uuid
|
215
|
+
::UUIDTools::UUID.random_create().to_s
|
216
|
+
end
|
217
|
+
|
190
218
|
end
|
191
219
|
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.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick McGraw
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 4.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: uuidtools
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.1.5
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.1.5
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|