auth0 4.17.0 → 5.1.1

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +29 -8
  3. data/.github/CODEOWNERS +1 -1
  4. data/.github/ISSUE_TEMPLATE/config.yml +8 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
  6. data/.github/ISSUE_TEMPLATE/report_a_bug.md +55 -0
  7. data/.gitignore +1 -1
  8. data/.yardoc/checksums +22 -0
  9. data/.yardoc/complete +0 -0
  10. data/.yardoc/object_types +0 -0
  11. data/.yardoc/objects/root.dat +0 -0
  12. data/.yardoc/proxy_types +0 -0
  13. data/CHANGELOG.md +79 -0
  14. data/Gemfile +0 -1
  15. data/README.md +81 -8
  16. data/Rakefile +0 -22
  17. data/auth0.gemspec +4 -3
  18. data/examples/ruby-api/.gitignore +0 -6
  19. data/lib/auth0/api/authentication_endpoints.rb +22 -226
  20. data/lib/auth0/api/v2.rb +8 -4
  21. data/lib/auth0/api/v2/branding.rb +66 -0
  22. data/lib/auth0/api/v2/connections.rb +3 -0
  23. data/lib/auth0/api/v2/jobs.rb +3 -1
  24. data/lib/auth0/api/v2/organizations.rb +335 -0
  25. data/lib/auth0/api/v2/tickets.rb +14 -2
  26. data/lib/auth0/api/v2/users.rb +20 -6
  27. data/lib/auth0/exception.rb +4 -7
  28. data/lib/auth0/mixins.rb +0 -1
  29. data/lib/auth0/mixins/access_token_struct.rb +2 -2
  30. data/lib/auth0/mixins/api_token_struct.rb +2 -2
  31. data/lib/auth0/mixins/initializer.rb +4 -8
  32. data/lib/auth0/mixins/permission_struct.rb +2 -2
  33. data/lib/auth0/mixins/validation.rb +15 -1
  34. data/lib/auth0/version.rb +1 -1
  35. data/spec/integration/lib/auth0/api/api_authentication_spec.rb +1 -1
  36. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +1 -1
  37. data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +1 -1
  38. data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +1 -1
  39. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +1 -1
  40. data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
  41. data/spec/lib/auth0/api/v2/connections_spec.rb +4 -0
  42. data/spec/lib/auth0/api/v2/jobs_spec.rb +11 -0
  43. data/spec/lib/auth0/api/v2/organizations_spec.rb +593 -0
  44. data/spec/lib/auth0/api/v2/roles_spec.rb +4 -4
  45. data/spec/lib/auth0/api/v2/tickets_spec.rb +55 -0
  46. data/spec/lib/auth0/api/v2/users_spec.rb +39 -10
  47. data/spec/lib/auth0/client_spec.rb +79 -9
  48. data/spec/lib/auth0/mixins/validation_spec.rb +32 -0
  49. data/spec/spec_helper.rb +6 -1
  50. data/spec/support/credentials.rb +0 -19
  51. metadata +49 -44
  52. data/.github/ISSUE_TEMPLATE.md +0 -39
  53. data/Gemfile.lock +0 -227
  54. data/deploy_documentation.sh +0 -29
  55. data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
  56. data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
  57. data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
  58. data/doc_config/templates/default/layout/html/footer.erb +0 -115
  59. data/doc_config/templates/default/layout/html/headers.erb +0 -17
  60. data/doc_config/templates/default/layout/html/layout.erb +0 -27
  61. data/lib/auth0/api/v1.rb +0 -19
  62. data/lib/auth0/api/v1/clients.rb +0 -58
  63. data/lib/auth0/api/v1/connections.rb +0 -68
  64. data/lib/auth0/api/v1/logs.rb +0 -43
  65. data/lib/auth0/api/v1/rules.rb +0 -57
  66. data/lib/auth0/api/v1/users.rb +0 -227
  67. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -703
@@ -9,6 +9,7 @@ module Auth0
9
9
  # being specified. Accepts a list of fields to include or exclude in the resulting list of connection objects.
10
10
  # @see https://auth0.com/docs/api/management/v2#!/Connections/get_connections
11
11
  # @param strategy [string] Strategy to filter connection results.
12
+ # @param name [string] Name to filter connection results.
12
13
  # @param fields [string] A comma separated list of fields to include or exclude from the result.
13
14
  # @param include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
14
15
  # @param page [int] Page number to get, 0-based.
@@ -16,6 +17,7 @@ module Auth0
16
17
  # @return [json] Returns the existing connections matching the strategy.
17
18
  def connections(
18
19
  strategy: nil,
20
+ name: nil,
19
21
  fields: nil,
20
22
  include_fields: nil,
21
23
  page: nil,
@@ -24,6 +26,7 @@ module Auth0
24
26
  include_fields = true if !fields.nil? && include_fields.nil?
25
27
  request_params = {
26
28
  strategy: strategy,
29
+ name: name,
27
30
  fields: fields.is_a?(Array) ? fields.join(',') : fields,
28
31
  include_fields: include_fields,
29
32
  page: !page.nil? ? page.to_i : nil,
@@ -81,13 +81,15 @@ module Auth0
81
81
  # @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
82
82
  # * :user_id [string] user_id of the identity.
83
83
  # * :provider [string] provider of the identity.
84
+ # @param organization_id [string] organization id
84
85
  #
85
86
  # @return [json] Returns the job status and properties.
86
- def send_verification_email(user_id, client_id = nil, identity: nil)
87
+ def send_verification_email(user_id, client_id = nil, identity: nil, organization_id: nil)
87
88
  raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
88
89
 
89
90
  request_params = { user_id: user_id }
90
91
  request_params[:client_id] = client_id unless client_id.nil?
92
+ request_params[:organization_id] = organization_id unless organization_id.nil?
91
93
 
92
94
  if identity
93
95
  unless identity.is_a? Hash
@@ -0,0 +1,335 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the organizations endpoints
5
+ module Organizations
6
+ include Auth0::Mixins::Validation
7
+
8
+ attr_reader :organizations_path
9
+
10
+ # Get all organizations.
11
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations
12
+ # @param options [hash] The Hash options used to define the paging of rersults
13
+ # * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
14
+ # * :page [integer] The page number. Zero based.
15
+ # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
16
+ # @return [json] All Organizations
17
+ def organizations(options = {})
18
+ request_params = {
19
+ per_page: options.fetch(:per_page, nil),
20
+ page: options.fetch(:page, nil),
21
+ include_totals: options.fetch(:include_totals, nil)
22
+ }
23
+ get(organizations_path, request_params)
24
+ end
25
+ alias get_organizations organizations
26
+
27
+ # Create a new organization.
28
+ # @see ttps://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations
29
+ # @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations for available options
30
+ # @return [json] Returns the created organization.
31
+ def create_organization(options = {})
32
+ post(organizations_path, options)
33
+ end
34
+
35
+ # Get an organization by id. A token with read:organizations scope is required
36
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations_by_id
37
+ # @param organization_id [string] The organization_id of the user to retrieve.
38
+ #
39
+ # @return [json] Returns the organization with the given organization_id if it exists.
40
+ def organization(organization_id)
41
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
42
+ path = "#{organizations_path}/#{organization_id}"
43
+ get(path)
44
+ end
45
+
46
+ # Get an organization by name. A token with read:organizations scope is required.
47
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_name_by_name
48
+ # @param organization_name [string] The Organization name
49
+ #
50
+ # @return [json] Returns the organization with the given organization_name if it exists.
51
+ def organization_by_name(organization_name)
52
+ raise Auth0::InvalidParameter, 'Must supply a valid organization_name' if organization_name.to_s.empty?
53
+ path = "#{organizations_path}/name/#{organization_name}"
54
+ get(path)
55
+ end
56
+
57
+
58
+ # Deletes a single organization given its id
59
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organizations_by_id
60
+ # @param organization_id [string] The Organization ID
61
+ def delete_organization(organization_id)
62
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
63
+ path = "#{organizations_path}/#{organization_id}"
64
+ delete(path)
65
+ end
66
+
67
+ # Update an existing organization.
68
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_organizations_by_id
69
+ # @param organization_id [string] The Organization ID
70
+ # @param body [hash] The optional parameters to update.
71
+ #
72
+ # @return [json] Returns the updated user.
73
+ def patch_organization(organization_id, body)
74
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
75
+ raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
76
+ path = "#{organizations_path}/#{organization_id}"
77
+ patch(path, body)
78
+ end
79
+ alias update_organization patch_organization
80
+
81
+ ### Organization Enabled Connections
82
+
83
+ # Get enabled connections in an Organization
84
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections
85
+ # @param organization_id [string] The Organization ID
86
+ #
87
+ # @return [json] Returns the enabled connections for the given organization
88
+ def get_organizations_enabled_connections(organization_id)
89
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
90
+ path = "#{organizations_enabled_connections_path(organization_id)}"
91
+ get(path)
92
+ end
93
+
94
+ # Get enabled connection by id in an Organization
95
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections_by_connectionId
96
+ # @param organization_id [string] The Organization ID
97
+ # @param connection_id [string] The Connection id
98
+ #
99
+ # @return [json] Returns the connection for the given organization
100
+ def get_organizations_enabled_connection(organization_id, connection_id)
101
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
102
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
103
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
104
+ get(path)
105
+ end
106
+
107
+ # Update an eanbled connection in an Organization
108
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_enabled_connections_by_connectionId
109
+ # @param organization_id [string] The Organization ID
110
+ # @param connection_id [string] The Connection id
111
+ # @param assign_membership_on_login [boolean] flag to allow assign membership on login
112
+ #
113
+ # @return [json] Returns the connection for the given organization
114
+ def patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil)
115
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
116
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
117
+ raise Auth0::InvalidParameter, 'Must supply a valid assign_membership_on_login value' if assign_membership_on_login.nil?
118
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
119
+
120
+ body = {}
121
+ body[:assign_membership_on_login] = assign_membership_on_login
122
+
123
+ patch(path, body)
124
+ end
125
+ alias update_organizations_enabled_connection patch_organizations_enabled_connection
126
+
127
+ # Add an enabled connection for an Organization
128
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_enabled_connections
129
+ # @param organization_id [string] The Organization ID
130
+ # @param connection_id [string] The Organization ID
131
+ # @param assign_membership_on_login [boolean] flag to allow assign membership on login
132
+ #
133
+ # @return [json] Returns the connection for the given organization
134
+ def create_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: false)
135
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
136
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
137
+ path = "#{organizations_enabled_connections_path(organization_id)}"
138
+
139
+ body = {}
140
+ body[:assign_membership_on_login] = assign_membership_on_login
141
+ body[:connection_id] = connection_id
142
+
143
+ post(path, body)
144
+ end
145
+ alias add_organizations_enabled_connection create_organizations_enabled_connection
146
+
147
+ # Remove an enabled connection from an Organization
148
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_enabled_connections_by_connectionId
149
+ # @param organization_id [string] The Organization ID
150
+ # @param connection_id [string] The Connection id
151
+ def delete_organizations_enabled_connection(organization_id, connection_id)
152
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
153
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
154
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
155
+ delete(path)
156
+ end
157
+ alias remove_organizations_enabled_connection delete_organizations_enabled_connection
158
+
159
+ ### Organization Invites
160
+
161
+ # Get invites in an Organization
162
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations
163
+ # @param organization_id [string] The Organization ID
164
+ #
165
+ # @return [json] Returns the invites for the given organization
166
+ def get_organizations_invites(organization_id)
167
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
168
+ path = "#{organizations_invitations_path(organization_id)}"
169
+ get(path)
170
+ end
171
+
172
+ # Get invite by id in an Organization
173
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations_by_invitation_id
174
+ # @param organization_id [string] The Organization ID
175
+ # @param invitation_id [string] The invitation id
176
+ #
177
+ # @return [json] Returns the invitation for the given organization
178
+ def get_organizations_invite(organization_id, invitation_id)
179
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
180
+ raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
181
+ path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
182
+ get(path)
183
+ end
184
+
185
+ # Create an invitation in an organization
186
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
187
+ # @param organization_id [string] The Organization ID
188
+ # @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
189
+ # @return [json] Returns the invitation for the given organization
190
+ def create_organizations_invite(organization_id, options = {})
191
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
192
+ path = "#{organizations_invitations_path(organization_id)}"
193
+
194
+ post(path, options)
195
+ end
196
+ alias add_organizations_invite create_organizations_invite
197
+
198
+ # Delete an invitation to organization
199
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_invitations_by_invitation_id
200
+ # @param organization_id [string] The Organization ID
201
+ # @param invitation_id [string] The Invitation id
202
+ def delete_organizations_invite(organization_id, invitation_id)
203
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
204
+ raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
205
+ path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
206
+ delete(path)
207
+ end
208
+ alias remove_organizations_invite delete_organizations_invite
209
+
210
+ ### Organization Member
211
+
212
+ # Get Members in a Organization
213
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
214
+ # @param organization_id [string] The Organization ID
215
+ # @param user_id [string] The User ID
216
+ #
217
+ # @return [json] Returns the members for the given organization
218
+ def get_organizations_members(organization_id)
219
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
220
+ path = "#{organizations_members_path(organization_id)}"
221
+ get(path)
222
+ end
223
+
224
+ # Add members in an organization
225
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_members
226
+ # @param organization_id [string] The Organization ID
227
+ # @param members [array] Array of user IDs.
228
+ #
229
+ # @return [json] Returns the invitation for the given organization
230
+ def create_organizations_members(organization_id, members = [])
231
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
232
+ raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
233
+ path = "#{organizations_members_path(organization_id)}"
234
+
235
+ body = {}
236
+ body[:members] = members
237
+
238
+ post(path, body)
239
+ end
240
+ alias add_organizations_members create_organizations_members
241
+
242
+ # Remove members from an organization
243
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_members
244
+ # @param organization_id [string] The Organization ID
245
+ # @param members [array] Array of user IDs.
246
+ def delete_organizations_members(organization_id, members = [])
247
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
248
+ raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
249
+ path = "#{organizations_members_path(organization_id)}"
250
+
251
+ body = {}
252
+ body[:members] = members
253
+
254
+ delete(path, body)
255
+ end
256
+ alias remove_organizations_members delete_organizations_members
257
+
258
+ ### Organization Member Roles
259
+
260
+ # Get Roles assigned to a Member in an Organization
261
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organization_member_roles
262
+ # @param organization_id [string] The Organization ID
263
+ # @param user_id [string] The User ID
264
+ #
265
+ # @return [json] Returns the member_roles for the given organization
266
+ def get_organizations_member_roles(organization_id, user_id)
267
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
268
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
269
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
270
+ get(path)
271
+ end
272
+
273
+ # Assign roles to a member in an organization
274
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_organization_member_roles
275
+ # @param organization_id [string] The Organization ID
276
+ # @param user_id [string] The User ID
277
+ # @param roles [array] Array of role IDs.
278
+ #
279
+ # @return [json] Returns the invitation for the given organization
280
+ def create_organizations_member_roles(organization_id, user_id, roles = [])
281
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
282
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
283
+ raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
284
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
285
+
286
+ body = {}
287
+ body[:roles] = roles
288
+
289
+ post(path, body)
290
+ end
291
+ alias add_organizations_member_roles create_organizations_member_roles
292
+
293
+ # Remove roles from a Member of an organization
294
+ # @https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organization_member_roles
295
+ # @param organization_id [string] The Organization ID
296
+ # @param user_id [string] The User ID
297
+ # @param roles [array] Array of role IDs.
298
+ def delete_organizations_member_roles(organization_id, user_id, roles = [])
299
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
300
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
301
+ raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
302
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
303
+
304
+ body = {}
305
+ body[:roles] = roles
306
+
307
+ delete(path, body)
308
+ end
309
+ alias remove_organizations_member_roles delete_organizations_member_roles
310
+
311
+ private
312
+ # Organizations API path
313
+ def organizations_path
314
+ @organizations_path ||= '/api/v2/organizations'
315
+ end
316
+
317
+ def organizations_enabled_connections_path(org_id)
318
+ "#{organizations_path}/#{org_id}/enabled_connections"
319
+ end
320
+
321
+ def organizations_members_path(org_id)
322
+ "#{organizations_path}/#{org_id}/members"
323
+ end
324
+
325
+ def organizations_member_roles_path(org_id, user_id)
326
+ "#{organizations_path}/#{org_id}/members/#{user_id}/roles"
327
+ end
328
+
329
+ def organizations_invitations_path(org_id)
330
+ "#{organizations_path}/#{org_id}/invitations"
331
+ end
332
+ end
333
+ end
334
+ end
335
+ end
@@ -15,9 +15,11 @@ module Auth0
15
15
  # @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
16
16
  # * :user_id [string] user_id of the identity.
17
17
  # * :provider [string] provider of the identity.
18
+ # @param client_id [string] client id
19
+ # @param organization_id [string] organization id
18
20
  #
19
21
  # @return [json] Returns the created ticket url.
20
- def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil)
22
+ def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil)
21
23
  if user_id.to_s.empty?
22
24
  raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
23
25
  end
@@ -27,6 +29,8 @@ module Auth0
27
29
  result_url: result_url,
28
30
  ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
29
31
  }
32
+ request_params[:client_id] = client_id unless client_id.nil?
33
+ request_params[:organization_id] = organization_id unless organization_id.nil?
30
34
 
31
35
  if identity
32
36
  unless identity.is_a? Hash
@@ -53,6 +57,8 @@ module Auth0
53
57
  # @param includeEmailInRedirect [boolean] Whether or not we include the email as part of the returnUrl
54
58
  # in the reset_email
55
59
  # @param new_password [string] The password to be set for the user once the ticket is used.
60
+ # @param client_id [string] client id
61
+ # @param organization_id [string] organization id
56
62
  #
57
63
  # @return [json] Returns the created ticket url.
58
64
  def post_password_change(
@@ -63,7 +69,10 @@ module Auth0
63
69
  ttl_sec: nil,
64
70
  mark_email_as_verified: nil,
65
71
  includeEmailInRedirect: nil,
66
- new_password: nil)
72
+ new_password: nil,
73
+ client_id: nil,
74
+ organization_id: nil
75
+ )
67
76
 
68
77
  booleans = [true, false]
69
78
  path = "#{tickets_path}/password-change"
@@ -77,6 +86,9 @@ module Auth0
77
86
  includeEmailInRedirect: booleans.include?(includeEmailInRedirect) ? includeEmailInRedirect : nil,
78
87
  new_password: new_password
79
88
  }
89
+ request_params[:client_id] = client_id unless client_id.nil?
90
+ request_params[:organization_id] = organization_id unless organization_id.nil?
91
+
80
92
  post(path, request_params)
81
93
  end
82
94
 
@@ -43,13 +43,15 @@ module Auth0
43
43
  # The attribute connection is always mandatory but depending on the type of connection you are using there
44
44
  # could be others too. For instance, Auth0 DB Connections require email and password.
45
45
  # @see https://auth0.com/docs/api/v2#!/Users/post_users
46
- # @param name [string] The user name.
47
- # @param options [hash]
48
- # * :connection [string] The connection the user belongs to.
46
+ # @param connection [string] The connection the user belongs to.
47
+ # @param options [hash] See https://auth0.com/docs/api/management/v2#!/Users/post_users for available options
49
48
  # @return [json] Returns the created user.
50
- def create_user(name, options = {})
49
+ def create_user(connection, options = {})
50
+ if !connection.is_a?(String) || connection.empty?
51
+ raise Auth0::MissingParameter, 'Must supply a valid connection'
52
+ end
51
53
  request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
52
- request_params[:name] = name
54
+ request_params[:connection] = connection
53
55
  post(users_path, request_params)
54
56
  end
55
57
 
@@ -294,7 +296,7 @@ module Auth0
294
296
  # @param user_id [string] The user_id of the recovery codes to regenerate.
295
297
  def generate_recovery_code(user_id)
296
298
  raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
297
- post "#{users_path}/#{user_id}/recovery-code-generation"
299
+ post "#{users_path}/#{user_id}/recovery-code-regeneration"
298
300
  end
299
301
 
300
302
  # Invalidate all remembered browsers for all authentication factors for a specific user.
@@ -306,6 +308,18 @@ module Auth0
306
308
  post "#{users_path}/#{user_id}/multifactor/actions/invalidate-remember-browser"
307
309
  end
308
310
 
311
+
312
+ # Get a list of organizations for a user.
313
+ #
314
+ # @param user_id [string] The user_id of the permissions to get.
315
+ #
316
+ # @return [json] Returns organizations for the given user_id.
317
+ def get_user_organizations(user_id)
318
+ raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
319
+
320
+ get "#{users_path}/#{user_id}/organizations"
321
+ end
322
+
309
323
  private
310
324
 
311
325
  # Users API path