Skip to content

Commit 19900d0

Browse files
phongnhSteve Hobbs
and
Steve Hobbs
authored
Add Delete All Authenticators API for Users (#375)
* https://auth0.com/docs/api/management/v2#!/Users/delete_authenticators Co-authored-by: Steve Hobbs <[email protected]>
1 parent 7158cfd commit 19900d0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Diff for: lib/auth0/api/v2/users.rb

+9
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ def patch_user(user_id, body)
111111
end
112112
alias update_user patch_user
113113

114+
# Delete all authenticators
115+
# @see https://auth0.com/docs/api/management/v2#!/Users/delete_authenticators
116+
# @param user_id [string] The user_id of the user to delete all authenticators
117+
def delete_user_authenticators(user_id)
118+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
119+
path = "#{users_path}/#{user_id}/authenticators"
120+
delete(path)
121+
end
122+
114123
# Delete a user's multifactor provider
115124
# @see https://auth0.com/docs/api/v2#!/Users/delete_multifactor_by_provider
116125
# @param user_id [string] The user_id of the user to delete the multifactor provider from.

Diff for: spec/lib/auth0/api/v2/users_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,21 @@
139139
end
140140
end
141141

142+
context '.delete_user_authenticators' do
143+
it 'is expected to respond to a delete_user_authenticators method' do
144+
expect(@instance).to respond_to(:delete_user_authenticators)
145+
end
146+
147+
it 'is expected to delete /api/v2/users/userId/authenticators' do
148+
expect(@instance).to receive(:delete).with('/api/v2/users/USER_ID/authenticators')
149+
@instance.delete_user_authenticators('USER_ID')
150+
end
151+
152+
it 'is expected to raise an exception when the user ID is empty' do
153+
expect { @instance.delete_user_authenticators(nil) }.to raise_exception(Auth0::MissingUserId)
154+
end
155+
end
156+
142157
context '.delete_user_provider' do
143158
it 'is expected to respond to a delete_user_provider method' do
144159
expect(@instance).to respond_to(:delete_user_provider)

0 commit comments

Comments
 (0)