@@ -329,6 +329,122 @@ def get_user_organizations(user_id)
329
329
get "#{ users_path } /#{ user_id } /organizations"
330
330
end
331
331
332
+ # Get the available authentication methods for a user.
333
+ #
334
+ # @param user_id [string] The user ID of the authentication methods to get
335
+ # @param options [hash] A hash of options for getting permissions
336
+ # * :per_page [integer] The amount of permissions per page. (optional)
337
+ # * :page [integer] The page number. Zero based. (optional)
338
+ # * :include_totals [boolean] True if a query summary must be included in the result. (optional)
339
+ # @return [json] The user's authentication methods
340
+ # @see https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods
341
+ def user_authentication_methods ( user_id , options = { } )
342
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
343
+
344
+ request_params = {
345
+ per_page : options . fetch ( :per_page , nil ) ,
346
+ page : options . fetch ( :page , nil ) ,
347
+ include_totals : options . fetch ( :include_totals , nil )
348
+ }
349
+
350
+ get "#{ users_path } /#{ user_id } /authentication-methods" , request_params
351
+ end
352
+ alias get_user_authentication_methods user_authentication_methods
353
+
354
+ # Get a specific authentication method for a user.
355
+ #
356
+ # @param user_id [string] The user ID of the authentication methods to get
357
+ # @param authentication_method_id [string] The ID of the authentication method
358
+ # @return [json] The user authentication method
359
+ # @see https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods_by_authentication_method_id
360
+ def user_authentication_method ( user_id , authentication_method_id )
361
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
362
+ raise Auth0 ::MissingParameter , 'Must supply a valid authentication_method_id' if authentication_method_id . to_s . empty?
363
+
364
+ get "#{ users_path } /#{ user_id } /authentication-methods/#{ authentication_method_id } "
365
+ end
366
+ alias get_user_authentication_method user_authentication_method
367
+
368
+ # Create an authentication method for a user
369
+ #
370
+ # @param user_id [string] The user ID of the authentication methods to get
371
+ # @param body [hash] The post body content
372
+ # * :type [string] "phone" or "email" or "totp" or "webauthn-roaming"
373
+ # * :name [string] A human-readable label to identify the authentication method (optional)
374
+ # * :totp_secret [string] Base32 encoded secret for TOTP generation (optional)
375
+ # * :phone_number [string] Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice (optional)
376
+ # * :email [string] Applies to email authentication methods only. The email address used to send verification messages (optional)
377
+ # * :preferred_authentication_method [string] Preferred phone authentication method (optional)
378
+ # * :key_id [string] Applies to email webauthn authenticators only. The id of the credential (optional)
379
+ # * :public_key [string] Applies to email webauthn authenticators only. The public key (optional)
380
+ # * :relying_party_identifier [string] Applies to email webauthn authenticators only. The relying party identifier (optional)
381
+ # @see https://auth0.com/docs/api/management/v2#!/Users/post_authentication_methods
382
+ def post_user_authentication_method ( user_id , body )
383
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
384
+ raise Auth0 ::MissingParameter , 'Must supply a body' if body . to_s . empty?
385
+
386
+ post "#{ users_path } /#{ user_id } /authentication-methods" , body
387
+ end
388
+ alias create_user_authentication_method post_user_authentication_method
389
+
390
+ # Updates all authentication methods by replacing them with the given ones
391
+ #
392
+ # @param user_id [string] The user ID of the authentication methods to get
393
+ # @param body [hash array] The mehods to update
394
+ # * :type [string] "phone" or "email" or "totp" or "webauthn-roaming"
395
+ # * :name [string] A human-readable label to identify the authentication method (optional)
396
+ # * :totp_secret [string] Base32 encoded secret for TOTP generation (optional)
397
+ # * :phone_number [string] Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice (optional)
398
+ # * :email [string] Applies to email authentication methods only. The email address used to send verification messages (optional)
399
+ # * :preferred_authentication_method [string] Preferred phone authentication method (optional)
400
+ # @see https://auth0.com/docs/api/management/v2#!/Users/put_authentication_methods
401
+ def put_all_user_authentication_methods ( user_id , body )
402
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
403
+ raise Auth0 ::MissingParameter , 'Must supply a body' if body . to_s . empty?
404
+
405
+ put "#{ users_path } /#{ user_id } /authentication-methods" , body
406
+ end
407
+ alias update_all_user_authentication_methods put_all_user_authentication_methods
408
+
409
+ # Updates a user authentication method
410
+ #
411
+ # @param user_id [string] The user ID of the authentication methods to get
412
+ # @param body [hash array] The mehods to update
413
+ # * :name [string] A human-readable label to identify the authentication method (optional)
414
+ # * :preferred_authentication_method [string] Preferred phone authentication method (optional)
415
+ # @see https://auth0.com/docs/api/management/v2#!/Users/put_authentication_methods
416
+ def patch_user_authentication_method ( user_id , authentication_method_id , body )
417
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
418
+ raise Auth0 ::MissingParameter , 'Must supply an authentication_method_id' if authentication_method_id . to_s . empty?
419
+ raise Auth0 ::MissingParameter , 'Must supply a body' if body . to_s . empty?
420
+
421
+ patch "#{ users_path } /#{ user_id } /authentication-methods/#{ authentication_method_id } " , body
422
+ end
423
+ alias update_user_authentication_method patch_user_authentication_method
424
+
425
+ # Deletes all of the user's authentication methods
426
+ #
427
+ # @param user_id [string] The user ID
428
+ # @see https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods
429
+ def delete_user_authentication_methods ( user_id )
430
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
431
+
432
+ delete "#{ users_path } /#{ user_id } /authentication-methods"
433
+ end
434
+
435
+
436
+ # Deletes the user's authentication method specified by authentication_method_id
437
+ #
438
+ # @param user_id [string] The user ID
439
+ # @param authentication_method_id [string] The ID of the authentication method
440
+ # @see https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods_by_authentication_method_id
441
+ def delete_user_authentication_method ( user_id , authentication_method_id )
442
+ raise Auth0 ::MissingUserId , 'Must supply a valid user_id' if user_id . to_s . empty?
443
+ raise Auth0 ::MissingParameter , 'Must supply an authentication_method_id' if authentication_method_id . to_s . empty?
444
+
445
+ delete "#{ users_path } /#{ user_id } /authentication-methods/#{ authentication_method_id } "
446
+ end
447
+
332
448
private
333
449
334
450
# Users API path
0 commit comments